32 lines
985 B
C#
32 lines
985 B
C#
using CH.CQRS.Service.Energy;
|
|
using CH.CQRS.Service.Energy.Options;
|
|
using FluentValidation;
|
|
using OpenHarbor.CQRS.Abstractions;
|
|
|
|
namespace CH.CQRS.Command.Energy;
|
|
|
|
public class DisableEnergyProviderCommand
|
|
{
|
|
public long ProviderId { get; set; }
|
|
public DateTime? DisabledAt { get; set; }
|
|
}
|
|
public class DisableEnergyProviderCommandHandler(EnergyService energyService) : ICommandHandler<DisableEnergyProviderCommand>
|
|
{
|
|
public Task HandleAsync(DisableEnergyProviderCommand command, CancellationToken cancellationToken = new CancellationToken())
|
|
{
|
|
return energyService.DisableEnergyProviderAsync(new DisableEnergyProviderCommandOptions
|
|
{
|
|
ProviderId = command.ProviderId,
|
|
DisabledAt = command.DisabledAt,
|
|
}, cancellationToken);
|
|
}
|
|
}
|
|
|
|
public class DisableEnergyProviderCommandValidator : AbstractValidator<DisableEnergyProviderCommand>
|
|
{
|
|
public DisableEnergyProviderCommandValidator()
|
|
{
|
|
RuleFor(command => command.ProviderId)
|
|
.NotEmpty();
|
|
}
|
|
} |