32 lines
951 B
C#
32 lines
951 B
C#
|
|
using CMSMicroservice.Protobuf.Protos.Configuration;
|
|
|
|
namespace BackOffice.BFF.Application.ConfigurationCQ.Commands.DeactivateConfiguration;
|
|
|
|
public class DeactivateConfigurationCommandHandler : IRequestHandler<DeactivateConfigurationCommand, Unit>
|
|
{
|
|
private readonly IApplicationContractContext _context;
|
|
|
|
public DeactivateConfigurationCommandHandler(IApplicationContractContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<Unit> Handle(DeactivateConfigurationCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var grpcRequest = new DeactivateConfigurationRequest
|
|
{
|
|
Key = request.Key
|
|
};
|
|
|
|
if (!string.IsNullOrWhiteSpace(request.Reason))
|
|
{
|
|
grpcRequest.Reason = request.Reason;
|
|
}
|
|
|
|
await _context.Configurations.DeactivateConfigurationAsync(grpcRequest, cancellationToken: cancellationToken);
|
|
|
|
return Unit.Value;
|
|
}
|
|
}
|