change price to rate
This commit is contained in:
parent
04ded7c21b
commit
ff1b284c25
@ -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<CreateEnergyRa
|
||||
return false == nameInUse;
|
||||
})
|
||||
.WithMessage("This Name is already in use by another energy rate.");
|
||||
RuleFor(command => command.Price).GreaterThanOrEqualTo(0);
|
||||
RuleFor(command => command.Rate).GreaterThanOrEqualTo(0);
|
||||
RuleFor(command => command.ProviderId)
|
||||
.NotEmpty()
|
||||
.SetValidator(new DbEntityExistValidator<EnergyProvider,long>(dbContext))
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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; }
|
||||
}
|
@ -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)
|
||||
|
@ -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; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user