2020-03-26 12:25:22 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediatR;
|
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
|
|
|
using ModernKeePass.Domain.Exceptions;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Group.Commands.RemoveEntry
|
|
|
|
|
{
|
|
|
|
|
public class RemoveEntryCommand : IRequest
|
|
|
|
|
{
|
2020-04-28 15:20:47 +02:00
|
|
|
|
public string ParentGroupId { get; set; }
|
|
|
|
|
public string EntryId { get; set; }
|
2020-03-26 12:25:22 +01:00
|
|
|
|
|
|
|
|
|
public class RemoveEntryCommandHandler : IAsyncRequestHandler<RemoveEntryCommand>
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabaseProxy _database;
|
|
|
|
|
|
2020-03-26 19:04:51 +01:00
|
|
|
|
public RemoveEntryCommandHandler(IDatabaseProxy database)
|
2020-03-26 12:25:22 +01:00
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Handle(RemoveEntryCommand message)
|
|
|
|
|
{
|
2020-03-26 19:04:51 +01:00
|
|
|
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
2020-03-26 12:25:22 +01:00
|
|
|
|
|
2020-04-28 15:20:47 +02:00
|
|
|
|
await _database.RemoveEntry(message.ParentGroupId, message.EntryId);
|
2020-03-26 12:25:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|