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 CreateEnergyProviderCommand
|
|
|
|
{
|
2025-01-10 15:59:51 -05:00
|
|
|
public required string Name { get; set; }
|
|
|
|
public bool Active { get; set; }
|
|
|
|
}
|
|
|
|
public class CreateEnergyProviderCommandHandler(EnergyService energyService) : ICommandHandler<CreateEnergyProviderCommand>
|
|
|
|
{
|
|
|
|
public Task HandleAsync(CreateEnergyProviderCommand command, CancellationToken cancellationToken = new CancellationToken())
|
|
|
|
{
|
|
|
|
return energyService.CreateEnergyProviderAsync(new CreateEnergyProviderCommandOptions
|
|
|
|
{
|
|
|
|
Name = command.Name,
|
|
|
|
Active = command.Active
|
|
|
|
},cancellationToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CreateEnergyProviderCommandValidator : AbstractValidator<CreateEnergyProviderCommand>
|
|
|
|
{
|
|
|
|
public CreateEnergyProviderCommandValidator()
|
|
|
|
{
|
2025-01-09 16:14:34 -05:00
|
|
|
|
2025-01-10 15:59:51 -05:00
|
|
|
}
|
2025-01-09 16:14:34 -05:00
|
|
|
}
|