diff --git a/CH.CQRS/Command/Energy/UpdateEnergyRateCommand.cs b/CH.CQRS/Command/Energy/UpdateEnergyRateCommand.cs index 59ef1f9..96890f7 100644 --- a/CH.CQRS/Command/Energy/UpdateEnergyRateCommand.cs +++ b/CH.CQRS/Command/Energy/UpdateEnergyRateCommand.cs @@ -4,6 +4,7 @@ using CH.CQRS.Service.Energy.Options; using CH.Dal; using CH.Dal.DbEntity; using CH.Dal.Validators; +using CH.Enum; using FluentValidation; using Microsoft.EntityFrameworkCore; using OpenHarbor.CQRS.Abstractions; @@ -16,6 +17,7 @@ public class UpdateEnergyRateCommand public string? Name { get; set; } public DateTime? StartedAt { get; set; } public decimal? Rate { get; set; } + public Currency Currency { get; set; } } public class UpdateEnergyRateCommandHandler(EnergyService energyService) : ICommandHandler { @@ -26,7 +28,8 @@ public class UpdateEnergyRateCommandHandler(EnergyService energyService) : IComm RateId = command.RateId, Name = command.Name, StartedAt = command.StartedAt, - Rate = command.Rate + Rate = command.Rate, + Currency = command.Currency }, cancellationToken); } } diff --git a/CH.CQRS/Service/Energy/EnergyService.cs b/CH.CQRS/Service/Energy/EnergyService.cs index 0c5568d..339733e 100644 --- a/CH.CQRS/Service/Energy/EnergyService.cs +++ b/CH.CQRS/Service/Energy/EnergyService.cs @@ -83,10 +83,11 @@ public class EnergyService(CHDbContext dbContext) if (options.Rate.HasValue) energyRate.Rate = options.Rate.Value; - + if (false == string.IsNullOrWhiteSpace(options.Name)) energyRate.Name = options.Name; + energyRate.Currency = options.Currency; energyRate.UpdatedAt = DateTime.UtcNow; } public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken) diff --git a/CH.CQRS/Service/Energy/Options/UpdateEnergyRateCommandOptions.cs b/CH.CQRS/Service/Energy/Options/UpdateEnergyRateCommandOptions.cs index 5e6469f..e8f3dfd 100644 --- a/CH.CQRS/Service/Energy/Options/UpdateEnergyRateCommandOptions.cs +++ b/CH.CQRS/Service/Energy/Options/UpdateEnergyRateCommandOptions.cs @@ -1,3 +1,5 @@ +using CH.Enum; + namespace CH.CQRS.Service.Energy.Options; public class UpdateEnergyRateCommandOptions @@ -6,4 +8,5 @@ public class UpdateEnergyRateCommandOptions public DateTime? StartedAt { get; set; } public decimal? Rate { get; set; } public string? Name { get; set; } + public Currency Currency { get; set; } } \ No newline at end of file