History *works*

WIP on save on entry page doesn't show last change
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-14 19:59:19 +02:00
parent 9603c1ff01
commit b66e79f97c
8 changed files with 54 additions and 115 deletions

View File

@@ -88,6 +88,7 @@
<Compile Include="Common\Interfaces\ISettingsProxy.cs" />
<Compile Include="Common\Mappings\IMapFrom.cs" />
<Compile Include="Common\Mappings\MappingProfile.cs" />
<Compile Include="Entry\Commands\AddHistory\AddHistoryCommand.cs" />
<Compile Include="Entry\Queries\GetEntry\GetEntryQuery.cs" />
<Compile Include="Group\Commands\DeleteEntry\DeleteEntryCommand.cs" />
<Compile Include="Group\Commands\DeleteGroup\DeleteGroupCommand.cs" />

View File

@@ -21,6 +21,7 @@ namespace ModernKeePass.Application.Common.Interfaces
Task Open(byte[] file, Credentials credentials);
Task ReOpen(byte[] file);
void AddHistory(string entryId);
Task Create(Credentials credentials, string name, DatabaseVersion version = DatabaseVersion.V2);
Task<byte[]> SaveDatabase();
Task<byte[]> SaveDatabase(byte[] newFileContents);

View File

@@ -0,0 +1,28 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Entry.Commands.AddHistory
{
public class AddHistoryCommand : IRequest
{
public string EntryId { get; set; }
public class AddHistoryCommandHandler : IRequestHandler<AddHistoryCommand>
{
private readonly IDatabaseProxy _database;
public AddHistoryCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public void Handle(AddHistoryCommand message)
{
if (!_database.IsOpen) throw new DatabaseClosedException();
_database.AddHistory(message.EntryId);
}
}
}
}

View File

@@ -28,6 +28,7 @@ namespace ModernKeePass.Application.Entry.Models
public bool HasExpirationDate { get; set; }
public DateTimeOffset ExpirationDate { get; set; }
public DateTimeOffset ModificationDate { get; set; }
public bool IsDirty { get; set; }
public override string ToString()
{