diff --git a/Project.Controller/Project.Controller.csproj b/Project.Controller/Project.Controller.csproj index 513f819..b01ca3b 100644 --- a/Project.Controller/Project.Controller.csproj +++ b/Project.Controller/Project.Controller.csproj @@ -5,6 +5,10 @@ + + + + net9.0 enable diff --git a/Project.Model/Project.Model.csproj b/Project.Model/Project.Model.csproj index 125f4c9..2633ae0 100644 --- a/Project.Model/Project.Model.csproj +++ b/Project.Model/Project.Model.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/Project.Persistence/CheckLogin.cs b/Project.Persistence/CheckLogin.cs new file mode 100644 index 0000000..dec6491 --- /dev/null +++ b/Project.Persistence/CheckLogin.cs @@ -0,0 +1,6 @@ +namespace Project.Persistence; + +public class CheckLogin +{ + +} \ No newline at end of file diff --git a/Project.Persistence/Project.Persistence.csproj b/Project.Persistence/Project.Persistence.csproj index 21e93f0..7431636 100644 --- a/Project.Persistence/Project.Persistence.csproj +++ b/Project.Persistence/Project.Persistence.csproj @@ -4,6 +4,10 @@ + + + + net9.0 enable diff --git a/Project.Persistence/SQLite.cs b/Project.Persistence/SQLite.cs new file mode 100644 index 0000000..beed5c8 --- /dev/null +++ b/Project.Persistence/SQLite.cs @@ -0,0 +1,24 @@ +using Microsoft.Data.Sqlite; +namespace Project.Persistence; + +public class SQLite +{ + private string _dbPath = "C:/Users/lowns/Desktop/logins.db"; + + public void Init() + { + using var connection = new SqliteConnection($"Data Source={_dbPath}"); + connection.Open(); + + var command = connection.CreateCommand(); + command.CommandText = + @" + CREATE TABLE IF NOT EXISTS logins ( + loginname STRING PRIMARY KEY NOT NULL, + loginpass STRING NOT NULL, + loginemail STRING NOT NULL + ); + "; + command.ExecuteNonQuery(); + } +} \ No newline at end of file diff --git a/Project.Persistence/NewLoginStorage.cs b/Project.Persistence/SaveNewLogin.cs similarity index 90% rename from Project.Persistence/NewLoginStorage.cs rename to Project.Persistence/SaveNewLogin.cs index 158a783..85d73d3 100644 --- a/Project.Persistence/NewLoginStorage.cs +++ b/Project.Persistence/SaveNewLogin.cs @@ -1,7 +1,7 @@ using Project.Model; namespace Project.Persistence; -public static class NewLoginStorage +public static class SaveNewLogin { private static readonly string FilePath = "C:/Users/lowns/desktop/users.txt"; public static void SaveUser(CreateLogin user) diff --git a/Project.View/App.axaml.cs b/Project.View/App.axaml.cs index 202097e..dcfe882 100644 --- a/Project.View/App.axaml.cs +++ b/Project.View/App.axaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Project.Persistence; namespace Project.View; @@ -16,6 +17,9 @@ public partial class App : Application if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow(); + // Initialising the database that contains all the logins + var initdb = new SQLite(); + initdb.Init(); } base.OnFrameworkInitializationCompleted(); diff --git a/Project.View/MainWindow.axaml.cs b/Project.View/MainWindow.axaml.cs index 90fb8f6..99d60a0 100644 --- a/Project.View/MainWindow.axaml.cs +++ b/Project.View/MainWindow.axaml.cs @@ -1,11 +1,13 @@ using Avalonia.Controls; using Project.Controller; +using Project.Persistence; namespace Project.View; public partial class MainWindow : Window { readonly AppController _controller; + public AppController AppController {get {return _controller;}} public MainWindow() { diff --git a/Project.View/NewLogin/NewLogin.axaml b/Project.View/NewLogin/NewLogin.axaml index bb81e29..744581d 100644 --- a/Project.View/NewLogin/NewLogin.axaml +++ b/Project.View/NewLogin/NewLogin.axaml @@ -6,7 +6,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - + None All +