mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Creation of a notification service
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
<Compile Include="Common\Interfaces\IFileProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IImportFormat.cs" />
|
||||
<Compile Include="Common\Interfaces\ICredentialsProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IProxyInvocationHandler.cs" />
|
||||
<Compile Include="Common\Interfaces\INotificationService.cs" />
|
||||
<Compile Include="Common\Interfaces\IRecentProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\IResourceProxy.cs" />
|
||||
<Compile Include="Common\Interfaces\ISettingsProxy.cs" />
|
||||
@@ -135,7 +135,6 @@
|
||||
<Compile Include="Security\Commands\GenerateKeyFile\GenerateKeyFileCommand.cs" />
|
||||
<Compile Include="Security\Commands\GeneratePassword\GeneratePasswordCommand.cs" />
|
||||
<Compile Include="Security\Queries\EstimatePasswordComplexity\EstimatePasswordComplexityQuery.cs" />
|
||||
<Content Include="Services\DatabaseService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
|
@@ -0,0 +1,7 @@
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface INotificationService
|
||||
{
|
||||
void Show(string title, string text);
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IProxyInvocationHandler
|
||||
{
|
||||
object Invoke(object proxy, MethodInfo method, object[] parameters);
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Application.Services
|
||||
{
|
||||
public class DatabaseService: IDatabaseService
|
||||
{
|
||||
private readonly IDatabaseProxy _databaseProxy;
|
||||
|
||||
public string Name { get; private set; }
|
||||
public bool IsOpen { get; private set; }
|
||||
public Domain.Entities.GroupEntity RootGroupEntity { get; private set; }
|
||||
public Domain.Entities.GroupEntity RecycleBin
|
||||
{
|
||||
get => _databaseProxy.RecycleBin;
|
||||
set => _databaseProxy.RecycleBin = value;
|
||||
}
|
||||
public Entity Cipher
|
||||
{
|
||||
get => _databaseProxy.Cipher;
|
||||
set => _databaseProxy.Cipher = value;
|
||||
}
|
||||
public Entity KeyDerivation
|
||||
{
|
||||
get => _databaseProxy.KeyDerivation;
|
||||
set => _databaseProxy.KeyDerivation = value;
|
||||
}
|
||||
public string Compression
|
||||
{
|
||||
get => _databaseProxy.Compression;
|
||||
set => _databaseProxy.Compression = value;
|
||||
}
|
||||
public bool IsRecycleBinEnabled => RecycleBin != null;
|
||||
|
||||
public DatabaseService(IDatabaseProxy databaseProxy)
|
||||
{
|
||||
_databaseProxy = databaseProxy;
|
||||
}
|
||||
|
||||
public async Task Open(FileInfo fileInfo, Credentials credentials)
|
||||
{
|
||||
RootGroupEntity = await _databaseProxy.Open(fileInfo, credentials);
|
||||
Name = RootGroupEntity?.Name;
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
public async Task Create(FileInfo fileInfo, Credentials credentials)
|
||||
{
|
||||
RootGroupEntity = await _databaseProxy.Create(fileInfo, credentials);
|
||||
Name = RootGroupEntity?.Name;
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
public async Task Save()
|
||||
{
|
||||
await _databaseProxy.SaveDatabase();
|
||||
}
|
||||
|
||||
public async Task SaveAs(FileInfo fileInfo)
|
||||
{
|
||||
await _databaseProxy.SaveDatabase(fileInfo);
|
||||
}
|
||||
|
||||
public Task CreateRecycleBin(Domain.Entities.GroupEntity recycleBinGroupEntity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task UpdateCredentials(Credentials credentials)
|
||||
{
|
||||
await _databaseProxy.UpdateCredentials(credentials);
|
||||
await Save();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_databaseProxy.CloseDatabase();
|
||||
IsOpen = false;
|
||||
}
|
||||
|
||||
public async Task AddEntity(GroupEntity parentEntity, Entity entity)
|
||||
{
|
||||
await _databaseProxy.AddEntity(parentEntity, entity);
|
||||
//await Save();
|
||||
}
|
||||
|
||||
public async Task UpdateEntity(Entity entity)
|
||||
{
|
||||
await _databaseProxy.UpdateEntity(entity);
|
||||
}
|
||||
|
||||
public async Task DeleteEntity(Entity entity)
|
||||
{
|
||||
if (IsRecycleBinEnabled) await AddEntity(RecycleBin, entity);
|
||||
await _databaseProxy.DeleteEntity(entity);
|
||||
//await Save();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user