2025-01-10 15:59:51 -05:00
|
|
|
using CH.CQRS.Service.Energy;
|
|
|
|
using CH.CQRS.Service.Energy.Options;
|
|
|
|
using FluentValidation;
|
|
|
|
using OpenHarbor.CQRS.Abstractions;
|
|
|
|
|
2025-01-09 16:14:34 -05:00
|
|
|
namespace CH.CQRS.Command.Energy;
|
|
|
|
|
|
|
|
public class UpdateEnergyProviderCommand
|
|
|
|
{
|
2025-01-10 15:59:51 -05:00
|
|
|
public long ProviderId { get; set; }
|
|
|
|
public required string Name { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public class UpdateEnergyProviderCommandHandler(EnergyService energyService) : ICommandHandler<UpdateEnergyProviderCommand>
|
|
|
|
{
|
|
|
|
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<UpdateEnergyProviderCommand>
|
|
|
|
{
|
|
|
|
public UpdateEnergyProviderCommandValidator()
|
|
|
|
{
|
|
|
|
RuleFor(command => command.ProviderId)
|
|
|
|
.NotEmpty();
|
|
|
|
}
|
2025-01-09 16:14:34 -05:00
|
|
|
}
|