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 { 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 { public DisableEnergyProviderCommandValidator() { RuleFor(command => command.ProviderId) .NotEmpty(); } }