mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00

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
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
} |