Renamed type to more descriptive name

This commit is contained in:
2025-10-29 13:23:56 +01:00
parent 81ef458d48
commit 99a3a7cc5c
6 changed files with 23 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ namespace Keychain.ViewModels;
public class BookmarkViewModel : INotifyPropertyChanged
{
private PasswordStore _model;
private Bookmark _model;
public event PropertyChangedEventHandler? PropertyChanged;
public string? DisplayName
@@ -18,16 +18,16 @@ public class BookmarkViewModel : INotifyPropertyChanged
get => _model.Path;
}
public PasswordStore Model { get => _model; }
public Bookmark Model { get => _model; }
public BookmarkViewModel(PasswordStore item)
public BookmarkViewModel(Bookmark item)
{
_model = item;
}
public BookmarkViewModel(string path, string? displayName = "New Shortcut")
{
_model = new PasswordStore
_model = new Bookmark
{
DisplayName = displayName,
Path = path,

View File

@@ -14,7 +14,7 @@ public class CollectionsService : ICollectionsService
this.secretService = secretService;
}
public bool Create(PasswordStore item)
public bool Create(Bookmark item)
{
if (secretService.CreateCollection(item.DisplayName ?? item.Path))
{
@@ -30,26 +30,26 @@ public class CollectionsService : ICollectionsService
repository.Delete(ID);
}
public void Delete(PasswordStore item)
public void Delete(Bookmark item)
{
Delete(item.ID);
}
public void Edit(uint ID, PasswordStore newItem)
public void Edit(uint ID, Bookmark newItem)
{
repository.Delete(ID);
newItem.ID = ID;
repository.Create(newItem);
}
public PasswordStore Get(uint ID)
public Bookmark Get(uint ID)
{
return repository.GetAll().FirstOrDefault(i => i.ID == ID) ?? throw new Exception("Item not found");
}
public IEnumerable<PasswordStore> GetAll()
public IEnumerable<Bookmark> GetAll()
{
List<PasswordStore> jsonResults = repository.GetAll();
List<Bookmark> jsonResults = repository.GetAll();
//Validate against actual secret collections
var collections = secretService.GetCollections() ?? Enumerable.Empty<Secret.Collection>();

View File

@@ -4,10 +4,10 @@ namespace Logic;
public interface ICollectionsService
{
IEnumerable<PasswordStore> GetAll();
PasswordStore Get(uint ID);
IEnumerable<Bookmark> GetAll();
Bookmark Get(uint ID);
void Delete(uint ID);
void Delete(PasswordStore item);
bool Create(PasswordStore item);
void Edit(uint ID, PasswordStore newItem);
void Delete(Bookmark item);
bool Create(Bookmark item);
void Edit(uint ID, Bookmark newItem);
}

View File

@@ -1,6 +1,6 @@
namespace Models;
public class PasswordStore
public class Bookmark
{
public uint ID { get; set; }
public string Path { get; set; }

View File

@@ -10,7 +10,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
private uint _autoIncrementedId;
private readonly string _filePath;
private List<PasswordStore> _cache;
private List<Bookmark> _cache;
private bool _cacheAhead;
public BookmarksRepository()
@@ -41,14 +41,14 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
private void ReadAllFromFile()
{
var items = new List<PasswordStore>();
var items = new List<Bookmark>();
if (File.Exists(_filePath))
{
try
{
string json = File.ReadAllText(_filePath);
items = JsonSerializer.Deserialize<List<PasswordStore>>(json) ?? new List<PasswordStore>();
items = JsonSerializer.Deserialize<List<Bookmark>>(json) ?? new List<Bookmark>();
}
catch (JsonException e)
{
@@ -68,7 +68,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
_cacheAhead = false;
}
public List<PasswordStore> GetAll()
public List<Bookmark> GetAll()
{
return _cache;
}
@@ -98,7 +98,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
}
}
public void Create(PasswordStore item)
public void Create(Bookmark item)
{
item.ID = ++_autoIncrementedId;
_cache.Add(item);

View File

@@ -5,7 +5,7 @@ namespace Repository;
public interface IBookmarksRepository
{
List<PasswordStore> GetAll();
void Create(PasswordStore item);
List<Bookmark> GetAll();
void Create(Bookmark item);
void Delete(uint ID);
}