diff --git a/App/Keychain.csproj b/App/Keychain.csproj
index 493b90e..415ac19 100644
--- a/App/Keychain.csproj
+++ b/App/Keychain.csproj
@@ -17,4 +17,8 @@
+
+
+
+
diff --git a/App/Program.cs b/App/Program.cs
index 737b9bf..ecd4b5d 100644
--- a/App/Program.cs
+++ b/App/Program.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
+using Logic;
namespace Keychain;
@@ -25,6 +26,7 @@ class Program
{
var services = new ServiceCollection();
//services.AddTransient();
+ services.AddSingleton();
return services.BuildServiceProvider();
}
}
\ No newline at end of file
diff --git a/App/UI/ViewModels/PasswordStoreShortcut.cs b/App/ViewModels/PasswordStoreShortcut.cs
similarity index 92%
rename from App/UI/ViewModels/PasswordStoreShortcut.cs
rename to App/ViewModels/PasswordStoreShortcut.cs
index 9b6792c..242cd2f 100644
--- a/App/UI/ViewModels/PasswordStoreShortcut.cs
+++ b/App/ViewModels/PasswordStoreShortcut.cs
@@ -1,9 +1,11 @@
using System.ComponentModel;
+using Logic;
-namespace Keychain.UI.ViewModels;
+namespace Keychain.ViewModels;
public class PasswordStoreShortcut : INotifyPropertyChanged
{
+ private IPasswordService passwordService;
public event PropertyChangedEventHandler? PropertyChanged;
private string displayName;
@@ -12,6 +14,7 @@ public class PasswordStoreShortcut : INotifyPropertyChanged
private string path;
public bool DisplayNameSet { get => displayNameSet; }
+
public string DisplayName
{
get => displayName;
diff --git a/App/UI/ViewModels/PasswordStoreShortcutCollection.cs b/App/ViewModels/PasswordStoreShortcutCollection.cs
similarity index 98%
rename from App/UI/ViewModels/PasswordStoreShortcutCollection.cs
rename to App/ViewModels/PasswordStoreShortcutCollection.cs
index 029c95a..ba79899 100644
--- a/App/UI/ViewModels/PasswordStoreShortcutCollection.cs
+++ b/App/ViewModels/PasswordStoreShortcutCollection.cs
@@ -1,4 +1,4 @@
-namespace Keychain.UI.ViewModels;
+namespace Keychain.ViewModels;
using Adw;
using Gtk;
diff --git a/Keychain.sln b/Keychain.sln
index 85c6cc3..479cb65 100644
--- a/Keychain.sln
+++ b/Keychain.sln
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Logic", "Logic\Logic.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keychain", "App\Keychain.csproj", "{D4755A56-58E0-46A3-859B-49ACAA3EDAED}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository", "Repository\Repository.csproj", "{AB25C193-3B52-46B4-BE6A-0B2E331BD2A8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
{D4755A56-58E0-46A3-859B-49ACAA3EDAED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4755A56-58E0-46A3-859B-49ACAA3EDAED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4755A56-58E0-46A3-859B-49ACAA3EDAED}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AB25C193-3B52-46B4-BE6A-0B2E331BD2A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AB25C193-3B52-46B4-BE6A-0B2E331BD2A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AB25C193-3B52-46B4-BE6A-0B2E331BD2A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AB25C193-3B52-46B4-BE6A-0B2E331BD2A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Logic/Class1.cs b/Logic/Class1.cs
deleted file mode 100644
index 1bb841d..0000000
--- a/Logic/Class1.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Logic;
-
-public class Class1
-{
-
-}
diff --git a/Logic/IPasswordStoreService.cs b/Logic/IPasswordStoreService.cs
new file mode 100644
index 0000000..7ceb3f3
--- /dev/null
+++ b/Logic/IPasswordStoreService.cs
@@ -0,0 +1,14 @@
+using Models;
+
+namespace Logic;
+
+public interface IPasswordStoreService
+{
+ IEnumerable GetAll();
+ PasswordStore Get(uint ID);
+ int Delete(uint ID);
+ int Delete(PasswordStore item);
+ int Create(string path, string? displayName = null, string? iconName = null);
+ int Create(PasswordStore item);
+ int Edit(uint ID, PasswordStore newItem);
+}
diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj
index 125f4c9..0a268a9 100644
--- a/Logic/Logic.csproj
+++ b/Logic/Logic.csproj
@@ -1,9 +1,14 @@
- net9.0
+ net8.0
enable
enable
+
+
+
+
+
diff --git a/Logic/PasswordStoreService.cs b/Logic/PasswordStoreService.cs
new file mode 100644
index 0000000..f0407d4
--- /dev/null
+++ b/Logic/PasswordStoreService.cs
@@ -0,0 +1,44 @@
+using Models;
+using Repository;
+
+namespace Logic;
+
+public class PasswordStoreService : IPasswordStoreService
+{
+ private readonly IRepository repository;
+
+ public int Create(string path, string? displayName = null, string? iconName = null)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int Create(PasswordStore item)
+ {
+ return Create(item.Path, item.DisplayName, item.IconName);
+ }
+
+ public int Delete(uint ID)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int Delete(PasswordStore item)
+ {
+ return Delete(item.ID);
+ }
+
+ public int Edit(uint ID, PasswordStore newItem)
+ {
+ throw new NotImplementedException();
+ }
+
+ public PasswordStore Get(uint ID)
+ {
+ return repository.ReadAll().Where(item => item.ID.Equals(ID)).First();
+ }
+
+ public IEnumerable GetAll()
+ {
+ return (IEnumerable)repository.ReadAll();
+ }
+}
diff --git a/Models/Models.csproj b/Models/Models.csproj
index 125f4c9..fa71b7a 100644
--- a/Models/Models.csproj
+++ b/Models/Models.csproj
@@ -1,7 +1,7 @@
- net9.0
+ net8.0
enable
enable
diff --git a/Models/PasswordStore.cs b/Models/PasswordStore.cs
index b2e7931..36243b7 100644
--- a/Models/PasswordStore.cs
+++ b/Models/PasswordStore.cs
@@ -2,7 +2,8 @@
public class PasswordStore
{
- private List passwordFiles;
-
-}
-
+ public uint ID;
+ public string Path;
+ public string? DisplayName;
+ public string? IconName;
+}
\ No newline at end of file
diff --git a/Repository/IRepository.cs b/Repository/IRepository.cs
new file mode 100644
index 0000000..af02874
--- /dev/null
+++ b/Repository/IRepository.cs
@@ -0,0 +1,10 @@
+using System.Collections;
+
+namespace Repository;
+
+public interface IRepository
+{
+ IEnumerable ReadAll();
+ void WriteAll(IEnumerable items);
+ object Get(uint id);
+}
\ No newline at end of file
diff --git a/Repository/Repository.cs b/Repository/Repository.cs
new file mode 100644
index 0000000..7df8078
--- /dev/null
+++ b/Repository/Repository.cs
@@ -0,0 +1,67 @@
+using System.Collections;
+using System.Text.Json;
+
+namespace Repository;
+
+public class Repository : IRepository
+{
+ private const string _appName = "Keychain";
+ private readonly string _filePath;
+ private List