Renamed type to more descriptive name
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Keychain.ViewModels;
|
|||||||
|
|
||||||
public class BookmarkViewModel : INotifyPropertyChanged
|
public class BookmarkViewModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private PasswordStore _model;
|
private Bookmark _model;
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
public string? DisplayName
|
public string? DisplayName
|
||||||
@@ -18,16 +18,16 @@ public class BookmarkViewModel : INotifyPropertyChanged
|
|||||||
get => _model.Path;
|
get => _model.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PasswordStore Model { get => _model; }
|
public Bookmark Model { get => _model; }
|
||||||
|
|
||||||
public BookmarkViewModel(PasswordStore item)
|
public BookmarkViewModel(Bookmark item)
|
||||||
{
|
{
|
||||||
_model = item;
|
_model = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BookmarkViewModel(string path, string? displayName = "New Shortcut")
|
public BookmarkViewModel(string path, string? displayName = "New Shortcut")
|
||||||
{
|
{
|
||||||
_model = new PasswordStore
|
_model = new Bookmark
|
||||||
{
|
{
|
||||||
DisplayName = displayName,
|
DisplayName = displayName,
|
||||||
Path = path,
|
Path = path,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class CollectionsService : ICollectionsService
|
|||||||
this.secretService = secretService;
|
this.secretService = secretService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(PasswordStore item)
|
public bool Create(Bookmark item)
|
||||||
{
|
{
|
||||||
if (secretService.CreateCollection(item.DisplayName ?? item.Path))
|
if (secretService.CreateCollection(item.DisplayName ?? item.Path))
|
||||||
{
|
{
|
||||||
@@ -30,26 +30,26 @@ public class CollectionsService : ICollectionsService
|
|||||||
repository.Delete(ID);
|
repository.Delete(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(PasswordStore item)
|
public void Delete(Bookmark item)
|
||||||
{
|
{
|
||||||
Delete(item.ID);
|
Delete(item.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Edit(uint ID, PasswordStore newItem)
|
public void Edit(uint ID, Bookmark newItem)
|
||||||
{
|
{
|
||||||
repository.Delete(ID);
|
repository.Delete(ID);
|
||||||
newItem.ID = ID;
|
newItem.ID = ID;
|
||||||
repository.Create(newItem);
|
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");
|
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
|
//Validate against actual secret collections
|
||||||
var collections = secretService.GetCollections() ?? Enumerable.Empty<Secret.Collection>();
|
var collections = secretService.GetCollections() ?? Enumerable.Empty<Secret.Collection>();
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ namespace Logic;
|
|||||||
|
|
||||||
public interface ICollectionsService
|
public interface ICollectionsService
|
||||||
{
|
{
|
||||||
IEnumerable<PasswordStore> GetAll();
|
IEnumerable<Bookmark> GetAll();
|
||||||
PasswordStore Get(uint ID);
|
Bookmark Get(uint ID);
|
||||||
void Delete(uint ID);
|
void Delete(uint ID);
|
||||||
void Delete(PasswordStore item);
|
void Delete(Bookmark item);
|
||||||
bool Create(PasswordStore item);
|
bool Create(Bookmark item);
|
||||||
void Edit(uint ID, PasswordStore newItem);
|
void Edit(uint ID, Bookmark newItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Models;
|
namespace Models;
|
||||||
|
|
||||||
public class PasswordStore
|
public class Bookmark
|
||||||
{
|
{
|
||||||
public uint ID { get; set; }
|
public uint ID { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
@@ -10,7 +10,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
|
|||||||
|
|
||||||
private uint _autoIncrementedId;
|
private uint _autoIncrementedId;
|
||||||
private readonly string _filePath;
|
private readonly string _filePath;
|
||||||
private List<PasswordStore> _cache;
|
private List<Bookmark> _cache;
|
||||||
private bool _cacheAhead;
|
private bool _cacheAhead;
|
||||||
|
|
||||||
public BookmarksRepository()
|
public BookmarksRepository()
|
||||||
@@ -41,14 +41,14 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
|
|||||||
|
|
||||||
private void ReadAllFromFile()
|
private void ReadAllFromFile()
|
||||||
{
|
{
|
||||||
var items = new List<PasswordStore>();
|
var items = new List<Bookmark>();
|
||||||
|
|
||||||
if (File.Exists(_filePath))
|
if (File.Exists(_filePath))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string json = File.ReadAllText(_filePath);
|
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)
|
catch (JsonException e)
|
||||||
{
|
{
|
||||||
@@ -68,7 +68,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
|
|||||||
_cacheAhead = false;
|
_cacheAhead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PasswordStore> GetAll()
|
public List<Bookmark> GetAll()
|
||||||
{
|
{
|
||||||
return _cache;
|
return _cache;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ public class BookmarksRepository : IBookmarksRepository, IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(PasswordStore item)
|
public void Create(Bookmark item)
|
||||||
{
|
{
|
||||||
item.ID = ++_autoIncrementedId;
|
item.ID = ++_autoIncrementedId;
|
||||||
_cache.Add(item);
|
_cache.Add(item);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Repository;
|
|||||||
|
|
||||||
public interface IBookmarksRepository
|
public interface IBookmarksRepository
|
||||||
{
|
{
|
||||||
List<PasswordStore> GetAll();
|
List<Bookmark> GetAll();
|
||||||
void Create(PasswordStore item);
|
void Create(Bookmark item);
|
||||||
void Delete(uint ID);
|
void Delete(uint ID);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user