using CH.CQRS.Service.Energy; using CH.CQRS.Service.Energy.Options; using FluentValidation; using OpenHarbor.CQRS.Abstractions; namespace CH.CQRS.Command.Energy; public class UpdateEnergyProviderCommand { public long ProviderId { get; set; } public required string Name { get; set; } } public class UpdateEnergyProviderCommandHandler(EnergyService energyService) : ICommandHandler { public Task HandleAsync(UpdateEnergyProviderCommand command, CancellationToken cancellationToken = new CancellationToken()) { return energyService.UpdateEnergyProviderAsync(new UpdateEnergyProviderCommandOptions { ProviderId = command.ProviderId, Name = command.Name },cancellationToken); } } public class UpdateEnergyProviderCommandValidator : AbstractValidator { public UpdateEnergyProviderCommandValidator() { RuleFor(command => command.ProviderId) .NotEmpty(); } }