using CH.CQRS.Service.Energy; using CH.CQRS.Service.Energy.Options; using FluentValidation; using OpenHarbor.CQRS.Abstractions; namespace CH.CQRS.Command.Energy; public class DisableEnergyRateCommand { public long RateId { get; set; } public DateTime? DisabledAt { get; set; } } public class DisableEnergyRateCommandHandler(EnergyService energyService) : ICommandHandler { public Task HandleAsync(DisableEnergyRateCommand command, CancellationToken cancellationToken = new CancellationToken()) { return energyService.DisableEnergyRateAsync(new DisableEnergyRateCommandOptions { RateId = command.RateId, DisabledAt = command.DisabledAt }, cancellationToken); } } public class DisableEnergyRateCommandValidator : AbstractValidator { public DisableEnergyRateCommandValidator() { RuleFor(command => command.RateId) .NotEmpty(); } }