2020-03-27 13:27:29 +01:00
|
|
|
|
using MediatR;
|
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
|
|
|
using ModernKeePass.Domain.Exceptions;
|
|
|
|
|
|
2020-03-27 18:45:13 +01:00
|
|
|
|
namespace ModernKeePass.Application.Parameters.Commands.SetCipher
|
2020-03-27 13:27:29 +01:00
|
|
|
|
{
|
|
|
|
|
public class SetCipherCommand : IRequest
|
|
|
|
|
{
|
|
|
|
|
public string CipherId { get; set; }
|
|
|
|
|
|
|
|
|
|
public class SetCipherCommandHandler : IRequestHandler<SetCipherCommand>
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabaseProxy _database;
|
|
|
|
|
|
|
|
|
|
public SetCipherCommandHandler(IDatabaseProxy database)
|
|
|
|
|
{
|
|
|
|
|
_database = database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(SetCipherCommand message)
|
|
|
|
|
{
|
|
|
|
|
if (_database.IsOpen) _database.CipherId = message.CipherId;
|
|
|
|
|
else throw new DatabaseClosedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|