add currency in update command
This commit is contained in:
parent
ef674cefea
commit
0ba2e45b38
@ -4,6 +4,7 @@ using CH.CQRS.Service.Energy.Options;
|
|||||||
using CH.Dal;
|
using CH.Dal;
|
||||||
using CH.Dal.DbEntity;
|
using CH.Dal.DbEntity;
|
||||||
using CH.Dal.Validators;
|
using CH.Dal.Validators;
|
||||||
|
using CH.Enum;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using OpenHarbor.CQRS.Abstractions;
|
using OpenHarbor.CQRS.Abstractions;
|
||||||
@ -16,6 +17,7 @@ public class UpdateEnergyRateCommand
|
|||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public DateTime? StartedAt { get; set; }
|
public DateTime? StartedAt { get; set; }
|
||||||
public decimal? Rate { get; set; }
|
public decimal? Rate { get; set; }
|
||||||
|
public Currency Currency { get; set; }
|
||||||
}
|
}
|
||||||
public class UpdateEnergyRateCommandHandler(EnergyService energyService) : ICommandHandler<UpdateEnergyRateCommand>
|
public class UpdateEnergyRateCommandHandler(EnergyService energyService) : ICommandHandler<UpdateEnergyRateCommand>
|
||||||
{
|
{
|
||||||
@ -26,7 +28,8 @@ public class UpdateEnergyRateCommandHandler(EnergyService energyService) : IComm
|
|||||||
RateId = command.RateId,
|
RateId = command.RateId,
|
||||||
Name = command.Name,
|
Name = command.Name,
|
||||||
StartedAt = command.StartedAt,
|
StartedAt = command.StartedAt,
|
||||||
Rate = command.Rate
|
Rate = command.Rate,
|
||||||
|
Currency = command.Currency
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,11 @@ public class EnergyService(CHDbContext dbContext)
|
|||||||
|
|
||||||
if (options.Rate.HasValue)
|
if (options.Rate.HasValue)
|
||||||
energyRate.Rate = options.Rate.Value;
|
energyRate.Rate = options.Rate.Value;
|
||||||
|
|
||||||
if (false == string.IsNullOrWhiteSpace(options.Name))
|
if (false == string.IsNullOrWhiteSpace(options.Name))
|
||||||
energyRate.Name = options.Name;
|
energyRate.Name = options.Name;
|
||||||
|
|
||||||
|
energyRate.Currency = options.Currency;
|
||||||
energyRate.UpdatedAt = DateTime.UtcNow;
|
energyRate.UpdatedAt = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken)
|
public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using CH.Enum;
|
||||||
|
|
||||||
namespace CH.CQRS.Service.Energy.Options;
|
namespace CH.CQRS.Service.Energy.Options;
|
||||||
|
|
||||||
public class UpdateEnergyRateCommandOptions
|
public class UpdateEnergyRateCommandOptions
|
||||||
@ -6,4 +8,5 @@ public class UpdateEnergyRateCommandOptions
|
|||||||
public DateTime? StartedAt { get; set; }
|
public DateTime? StartedAt { get; set; }
|
||||||
public decimal? Rate { get; set; }
|
public decimal? Rate { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
public Currency Currency { get; set; }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user