mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00
Added the option to close DB without saving
Changed the way recent files are retrieved Stopped showing the DB Closed exception on suspend Reordering entries works Moved code from infra to application Cleanup
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Entry.Models;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Group.Commands.MoveEntry
|
||||
{
|
||||
public class MoveEntryCommand : IRequest
|
||||
{
|
||||
public GroupVm ParentGroup { get; set; }
|
||||
public EntryVm Entry { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public class MoveEntryCommandHandler : IAsyncRequestHandler<MoveEntryCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public MoveEntryCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task Handle(MoveEntryCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
await _database.MoveEntry(message.ParentGroup.Id, message.Entry.Id, message.Index);
|
||||
message.ParentGroup.Entries.Insert(message.Index, message.Entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user