2020-03-27 18:45:13 +01:00
|
|
|
|
using MediatR;
|
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
|
|
|
using ModernKeePass.Domain.Exceptions;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
|
|
|
|
|
{
|
|
|
|
|
public class SetRecycleBinCommand : IRequest
|
|
|
|
|
{
|
2020-04-03 17:33:53 +02:00
|
|
|
|
public string RecycleBinId { get; set; }
|
2020-03-27 18:45:13 +01:00
|
|
|
|
|
|
|
|
|
public class SetRecycleBinCommandHandler : IRequestHandler<SetRecycleBinCommand>
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabaseProxy _database;
|
|
|
|
|
|
|
|
|
|
public SetRecycleBinCommandHandler(IDatabaseProxy database)
|
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(SetRecycleBinCommand message)
|
|
|
|
|
{
|
2020-04-03 17:33:53 +02:00
|
|
|
|
if (_database.IsOpen) _database.SetRecycleBin(message.RecycleBinId);
|
2020-03-27 18:45:13 +01:00
|
|
|
|
else throw new DatabaseClosedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|