More commands/queries

WIP on XAML EntryVm and GroupVm
This commit is contained in:
Geoffroy BONNEVILLE
2020-03-27 13:27:29 +01:00
parent 22072bb2fe
commit e3638c2f5c
24 changed files with 344 additions and 227 deletions

View File

@@ -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.InsertEntry
{
public class InsertEntryCommand : IRequest
{
public GroupVm ParentGroup { get; set; }
public EntryVm Entry { get; set; }
public int Index { get; set; }
public class InsertEntryCommandHandler : IAsyncRequestHandler<InsertEntryCommand>
{
private readonly IDatabaseProxy _database;
public InsertEntryCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public async Task Handle(InsertEntryCommand message)
{
if (!_database.IsOpen) throw new DatabaseClosedException();
await _database.InsertEntry(message.ParentGroup.Id, message.Entry.Id, message.Index);
message.ParentGroup.Entries.Insert(message.Index, message.Entry);
}
}
}
}