From ff1b284c254b642b6481c9c9c602936d3e76410c Mon Sep 17 00:00:00 2001 From: DavidGudEnough Date: Mon, 20 Jan 2025 18:14:38 -0500 Subject: [PATCH] change price to rate --- CH.CQRS/Command/Energy/CreateEnergyRateCommand.cs | 6 +++--- CH.CQRS/Service/Energy/EnergyService.cs | 6 +++--- .../Energy/Options/CreateEnergyRateCommandOptions.cs | 2 +- CH.Dal/CHDbScaffoldedContext.cs | 2 +- CH.Dal/DbEntity/EnergyRate.cs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CH.CQRS/Command/Energy/CreateEnergyRateCommand.cs b/CH.CQRS/Command/Energy/CreateEnergyRateCommand.cs index d274010..8a3d6da 100644 --- a/CH.CQRS/Command/Energy/CreateEnergyRateCommand.cs +++ b/CH.CQRS/Command/Energy/CreateEnergyRateCommand.cs @@ -14,7 +14,7 @@ public class CreateEnergyRateCommand { public long ProviderId { get; set; } public required string Name { get; set; } - public decimal Price { get; set; } + public decimal Rate { get; set; } public Currency Currency { get; set; } public bool Active { get; set; } } @@ -26,7 +26,7 @@ public class CreateEnergyRateCommandHandler(EnergyService energyService) : IComm { ProviderId = command.ProviderId, Name = command.Name, - Price = command.Price, + Rate = command.Rate, Currency = command.Currency, Active = command.Active },cancellationToken); @@ -46,7 +46,7 @@ public class CreateEnergyRateCommandValidator : AbstractValidator command.Price).GreaterThanOrEqualTo(0); + RuleFor(command => command.Rate).GreaterThanOrEqualTo(0); RuleFor(command => command.ProviderId) .NotEmpty() .SetValidator(new DbEntityExistValidator(dbContext)) diff --git a/CH.CQRS/Service/Energy/EnergyService.cs b/CH.CQRS/Service/Energy/EnergyService.cs index 7764dc8..a8bc471 100644 --- a/CH.CQRS/Service/Energy/EnergyService.cs +++ b/CH.CQRS/Service/Energy/EnergyService.cs @@ -29,7 +29,7 @@ public class EnergyService(CHDbContext dbContext) { Name = options.Name, Currency = options.Currency, - Price = options.Price, + Rate = options.Rate, CreatedAt = DateTime.UtcNow, Provider = provider, Active = options.Active @@ -82,7 +82,7 @@ public class EnergyService(CHDbContext dbContext) return; if (options.Rate.HasValue) - energyRate.Price = options.Rate.Value; + energyRate.Rate = options.Rate.Value; if (false == string.IsNullOrWhiteSpace(options.Name)) energyRate.Name = options.Name; @@ -91,7 +91,7 @@ public class EnergyService(CHDbContext dbContext) } public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken) { - if (options.StartedAt.HasValue) + if (options.StartedAt > DateTime.UtcNow) { var energyRateUpdate = new EnergyRateUpdate { diff --git a/CH.CQRS/Service/Energy/Options/CreateEnergyRateCommandOptions.cs b/CH.CQRS/Service/Energy/Options/CreateEnergyRateCommandOptions.cs index 3447ddc..2298aeb 100644 --- a/CH.CQRS/Service/Energy/Options/CreateEnergyRateCommandOptions.cs +++ b/CH.CQRS/Service/Energy/Options/CreateEnergyRateCommandOptions.cs @@ -7,7 +7,7 @@ public class CreateEnergyRateCommandOptions { public long ProviderId { get; set; } public required string Name { get; set; } - public decimal? Price { get; set; } + public decimal? Rate { get; set; } public Currency Currency { get; set; } public bool Active { get; set; } } \ No newline at end of file diff --git a/CH.Dal/CHDbScaffoldedContext.cs b/CH.Dal/CHDbScaffoldedContext.cs index c08baac..6045a45 100644 --- a/CH.Dal/CHDbScaffoldedContext.cs +++ b/CH.Dal/CHDbScaffoldedContext.cs @@ -72,8 +72,8 @@ public partial class CHDbScaffoldedContext : DbContext entity.Property(e => e.Name) .HasMaxLength(255) .HasColumnName("name"); - entity.Property(e => e.Price).HasColumnName("price"); entity.Property(e => e.ProviderId).HasColumnName("provider_id"); + entity.Property(e => e.Rate).HasColumnName("rate"); entity.Property(e => e.UpdatedAt).HasColumnName("updated_at"); entity.HasOne(d => d.Provider).WithMany(p => p.EnergyRates) diff --git a/CH.Dal/DbEntity/EnergyRate.cs b/CH.Dal/DbEntity/EnergyRate.cs index 463493a..d7246b6 100644 --- a/CH.Dal/DbEntity/EnergyRate.cs +++ b/CH.Dal/DbEntity/EnergyRate.cs @@ -11,7 +11,7 @@ public partial class EnergyRate public string Name { get; set; } = null!; - public decimal? Price { get; set; } + public decimal? Rate { get; set; } public bool Active { get; set; }