mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP History
Restore from history works
This commit is contained in:
@@ -89,6 +89,7 @@
|
||||
<Compile Include="Common\Mappings\IMapFrom.cs" />
|
||||
<Compile Include="Common\Mappings\MappingProfile.cs" />
|
||||
<Compile Include="Entry\Commands\AddHistory\AddHistoryCommand.cs" />
|
||||
<Compile Include="Entry\Commands\RestoreHistory\RestoreHistoryCommand.cs" />
|
||||
<Compile Include="Entry\Queries\GetEntry\GetEntryQuery.cs" />
|
||||
<Compile Include="Group\Commands\DeleteEntry\DeleteEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\DeleteGroup\DeleteGroupCommand.cs" />
|
||||
|
@@ -22,7 +22,6 @@ 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);
|
||||
@@ -44,6 +43,9 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
void SortEntries(string groupId);
|
||||
void SortSubGroups(string groupId);
|
||||
|
||||
void AddHistory(string entryId);
|
||||
void RestoreFromHistory(string entryId, int historyIndex);
|
||||
|
||||
IEnumerable<EntryEntity> Search(string groupId, string text);
|
||||
}
|
||||
}
|
@@ -51,7 +51,7 @@ namespace ModernKeePass.Application.Database.Commands.SaveDatabase
|
||||
|
||||
_database.IsDirty = false;
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new SaveException(exception);
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Commands.RestoreHistory
|
||||
{
|
||||
public class RestoreHistoryCommand : IRequest
|
||||
{
|
||||
public string EntryId { get; set; }
|
||||
public int HistoryIndex { get; set; }
|
||||
|
||||
public class RestoreHistoryCommandHandler : IRequestHandler<RestoreHistoryCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public RestoreHistoryCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(RestoreHistoryCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
_database.RestoreFromHistory(message.EntryId, message.HistoryIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user