using CH.CQRS.Service.Energy; using CH.CQRS.Service.Energy.Options; using FluentValidation; using OpenHarbor.CQRS.Abstractions; namespace CH.CQRS.Command.Energy; public class UpdateEnergyRateCommand { public long RateId { get; set; } public bool SendAlert { get; set; } public required DateTime StartedAt { get; set; } public DateTime? AppliedAt { get; set; } public decimal? Rate { get; set; } public DateTime? UpdatedAt { get; set; } } public class UpdateEnergyRateCommandHandler(EnergyService energyService) : ICommandHandler { public Task HandleAsync(UpdateEnergyRateCommand command, CancellationToken cancellationToken = new CancellationToken()) { return energyService.UpdateEnergyRateAsync(new UpdateEnergyRateCommandOptions { RateId = command.RateId, StartedAt = command.StartedAt, AppliedAt = command.AppliedAt, Rate = command.Rate, SendAlert = command.SendAlert, UpdatedAt = command.UpdatedAt }, cancellationToken); } } public class UpdateEnergyRateCommandValidator : AbstractValidator { public UpdateEnergyRateCommandValidator() { } }