Files
Keys/src/Logic/PasswordStoreService.cs

47 lines
925 B
C#
Raw Normal View History

2025-09-22 13:08:08 +02:00
using Models;
using Repository;
namespace Logic;
public class PasswordStoreService : IPasswordStoreService
{
private readonly IRepository repository;
2025-09-30 11:31:38 +02:00
public PasswordStoreService(IRepository repository)
{
this.repository = repository;
}
2025-09-22 15:35:31 +02:00
public void Create(PasswordStore item)
2025-09-22 13:08:08 +02:00
{
repository.Create(item);
2025-09-22 13:08:08 +02:00
}
2025-09-22 15:35:31 +02:00
public void Delete(uint ID)
2025-09-22 13:08:08 +02:00
{
repository.Delete(ID);
2025-09-22 13:08:08 +02:00
}
2025-09-22 15:35:31 +02:00
public void Delete(PasswordStore item)
2025-09-22 13:08:08 +02:00
{
2025-09-22 15:35:31 +02:00
Delete(item.ID);
2025-09-22 13:08:08 +02:00
}
2025-09-22 15:35:31 +02:00
public void Edit(uint ID, PasswordStore newItem)
2025-09-22 13:08:08 +02:00
{
repository.Delete(ID);
newItem.ID = ID;
repository.Create(newItem);
2025-09-22 13:08:08 +02:00
}
public PasswordStore Get(uint ID)
{
return repository.GetAll().FirstOrDefault(i => i.ID == ID) ?? throw new Exception("Item not found");
2025-09-22 13:08:08 +02:00
}
public IEnumerable<PasswordStore> GetAll()
{
return repository.GetAll();
2025-09-22 13:08:08 +02:00
}
}