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.RemoveGroup
|
|
|
|
|
{
|
|
|
|
|
public class RemoveGroupCommand : IRequest
|
|
|
|
|
{
|
2020-04-28 15:20:47 +02:00
|
|
|
|
public string ParentGroupId { get; set; }
|
|
|
|
|
public string GroupId { get; set; }
|
2020-03-26 12:25:22 +01:00
|
|
|
|
|
|
|
|
|
public class RemoveGroupCommandHandler : IAsyncRequestHandler<RemoveGroupCommand>
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabaseProxy _database;
|
|
|
|
|
|
2020-03-26 19:04:51 +01:00
|
|
|
|
public RemoveGroupCommandHandler(IDatabaseProxy database)
|
2020-03-26 12:25:22 +01:00
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Handle(RemoveGroupCommand 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.RemoveGroup(message.ParentGroupId, message.GroupId);
|
2020-03-26 12:25:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|