mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Entry history delete and restore work
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Commands.DeleteHistory
|
||||
{
|
||||
public class DeleteHistoryCommand : IRequest
|
||||
{
|
||||
public string EntryId { get; set; }
|
||||
public int HistoryIndex { get; set; }
|
||||
|
||||
public class DeleteHistoryCommandHandler : IRequestHandler<DeleteHistoryCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public DeleteHistoryCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(DeleteHistoryCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
_database.DeleteHistory(message.EntryId, message.HistoryIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -28,7 +28,6 @@ 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()
|
||||
{
|
||||
@@ -47,7 +46,7 @@ namespace ModernKeePass.Application.Entry.Models
|
||||
.ForMember(d => d.Url, opts => opts.MapFrom(s => s.Url))
|
||||
.ForMember(d => d.Notes, opts => opts.MapFrom(s => s.Notes))
|
||||
.ForMember(d => d.AdditionalFields, opts => opts.MapFrom(s => s.AdditionalFields))
|
||||
.ForMember(d => d.History, opts => opts.MapFrom(s => s.History.OrderByDescending(h => h.LastModificationDate)))
|
||||
.ForMember(d => d.History, opts => opts.MapFrom(s => s.History.Reverse()))
|
||||
.ForMember(d => d.HasExpirationDate, opts => opts.MapFrom(s => s.HasExpirationDate))
|
||||
.ForMember(d => d.ExpirationDate, opts => opts.MapFrom(s => s.ExpirationDate))
|
||||
.ForMember(d => d.ModificationDate, opts => opts.MapFrom(s => s.LastModificationDate))
|
||||
|
Reference in New Issue
Block a user