Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ coverage
.vscode/*
!.vscode/extensions.json
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
1 change: 1 addition & 0 deletions ToDoList-WebApi.Server/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONNECTION_STRING=Data Source=./db/db.sqlite
67 changes: 67 additions & 0 deletions ToDoList-WebApi.Server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Common IntelliJ Platform excludes

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

*.suo
*.user
.vs/
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
[Pp]ackages/
.idea

Thumbs.db
Desktop.ini
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*.tsbuildinfo
32 changes: 15 additions & 17 deletions ToDoList-WebApi.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,24 @@
.AllowAnyMethod()
.AllowAnyHeader());

ApplicationContextUser dbUser = new ApplicationContextUser();
ApplicationContextNote dbNote = new ApplicationContextNote();
dbUser.Database.EnsureCreated();
dbNote.Database.EnsureCreated();
ApplicationContext db = new ApplicationContext();
db.Database.EnsureCreated();

app.MapPost("/register", async context => {
context.Response.ContentType = "application/json";
var userCredentials = await context.Request.ReadFromJsonAsync<Models.UserCredentials>();

User user = new User(userCredentials!.Username, userCredentials.Password);
User isCreated = dbUser.FindUserByName(userCredentials.Username);
User isCreated = db.FindUserByName(userCredentials.Username);

if (isCreated != null)
{
await context.Response.WriteAsJsonAsync(new { error = "taken" });
return;
}

dbUser.Users.Add(user);
dbUser.SaveChanges();
db.Users.Add(user);
db.SaveChanges();

Console.WriteLine($"/register | Username: {userCredentials.Username} Pass: {userCredentials.Password}");

Expand All @@ -43,7 +41,7 @@
context.Response.ContentType = "application/json";
var userCredentials = await context.Request.ReadFromJsonAsync<Models.UserCredentials>();

User isCreated = dbUser.FindUserByNameAndPassword(userCredentials!.Username, userCredentials.Password);
User isCreated = db.FindUserByNameAndPassword(userCredentials!.Username, userCredentials.Password);

if (isCreated == null)
{
Expand All @@ -60,7 +58,7 @@
var noteCredentials = await context.Request.ReadFromJsonAsync<Models.NoteCredentials>();

Console.WriteLine("/notes");
await context.Response.WriteAsJsonAsync(new { notes = dbNote.FindNotesByUsername(noteCredentials.Username)});
await context.Response.WriteAsJsonAsync(new { notes = db.FindNotesByUsername(noteCredentials.Username)});
});

app.MapPost("/notes/add", async context => {
Expand All @@ -69,8 +67,8 @@

Note note = new Note(noteCredentials!.Username, noteCredentials!.Title, noteCredentials!.Description);

dbNote.Notes.Add(note);
dbNote.SaveChanges();
db.Notes.Add(note);
db.SaveChanges();

Console.WriteLine($"/notes/add | Title: {noteCredentials!.Title} Description: {noteCredentials.Description}");
await context.Response.WriteAsJsonAsync(new { data = "2"});
Expand All @@ -80,10 +78,10 @@
context.Response.ContentType = "application/json";
var noteCredentials = await context.Request.ReadFromJsonAsync<Models.NoteCredentials>();

Note note = dbNote.FindNote(noteCredentials!.Username, noteCredentials!.Title, noteCredentials!.Description);
Note note = db.FindNote(noteCredentials!.Username, noteCredentials!.Title, noteCredentials!.Description);

dbNote.Notes.Remove(note);
dbNote.SaveChanges();
db.Notes.Remove(note);
db.SaveChanges();

Console.WriteLine($"/notes/delete | Title: {noteCredentials!.Title} Description: {noteCredentials.Description}");
await context.Response.WriteAsJsonAsync(new { data = "3"});
Expand All @@ -93,12 +91,12 @@
context.Response.ContentType = "application/json";
var editNoteCredentials = await context.Request.ReadFromJsonAsync<Models.EditNoteCredentials>();

Note note = dbNote.FindNote(editNoteCredentials!.Username, editNoteCredentials!.Title, editNoteCredentials!.Description);
Note note = db.FindNote(editNoteCredentials!.Username, editNoteCredentials!.Title, editNoteCredentials!.Description);
note.Title = editNoteCredentials.NewTitle;
note.Description = editNoteCredentials.NewDescription;

dbNote.Notes.Update(note);
dbNote.SaveChanges();
db.Notes.Update(note);
db.SaveChanges();

Console.WriteLine($"/notes/edit | Title: {editNoteCredentials!.NewTitle} Description: {editNoteCredentials.NewDescription}");
await context.Response.WriteAsJsonAsync(new { data = "3"});
Expand Down
1 change: 1 addition & 0 deletions ToDoList-WebApi.Server/ToDoList-WebApi.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
<Version>8.*-*</Version>
Expand Down
38 changes: 38 additions & 0 deletions ToDoList-WebApi.Server/db/DbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using DotNetEnv;

namespace SQLite
{
public class ApplicationContext : DbContext
{
public DbSet<User> Users { get; set; } = null!;
public DbSet<Note> Notes { get; set; } = null!;

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
Env.Load();
var connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING");
optionsBuilder.UseSqlite(connectionString);
}

public User FindUserByName(string name)
{
return Users.FirstOrDefault(u => u.Name == name);
}

public User FindUserByNameAndPassword(string name, string password)
{
return Users.FirstOrDefault(u => u.Name == name && u.Password == password);
}

public List<Note> FindNotesByUsername(string name)
{
return Notes.Where(u => u.Username == name).ToList();
}

public Note FindNote(string name, string title, string description)
{
return Notes.FirstOrDefault(u => u.Username == name && u.Title == title && u.Description == description);
}
}
}
25 changes: 0 additions & 25 deletions ToDoList-WebApi.Server/db/DbContextNote.cs

This file was deleted.

21 changes: 0 additions & 21 deletions ToDoList-WebApi.Server/db/DbContextUser.cs

This file was deleted.

Binary file not shown.
Binary file removed ToDoList-WebApi.Server/db/notes.db
Binary file not shown.
4 changes: 4 additions & 0 deletions ToDoList-WebApi.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
67 changes: 67 additions & 0 deletions todolist-webapi.client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Common IntelliJ Platform excludes

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

*.suo
*.user
.vs/
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
[Pp]ackages/
.idea

Thumbs.db
Desktop.ini
.DS_Store

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

*.tsbuildinfo
1 change: 0 additions & 1 deletion todolist-webapi.client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default {
display: flex;
justify-content: space-evenly;
align-items: center;
//background-image: linear-gradient(43deg, #4158D0 0%, #C850C0 46%, #FFCC70 100%);
background: linear-gradient(45deg,#9e9eff, #8000ff, #fecb70);
background-size: 300% 100%;
animation: gradient 12s linear infinite;
Expand Down
Empty file removed users.db
Empty file.