constellation-api/CH.CQRS/Command/Energy/CreateEnergyProviderCommand.cs

31 lines
893 B
C#
Raw Normal View History

using CH.CQRS.Service.Energy;
using CH.CQRS.Service.Energy.Options;
using FluentValidation;
using OpenHarbor.CQRS.Abstractions;
namespace CH.CQRS.Command.Energy;
public class CreateEnergyProviderCommand
{
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()
{
}
}