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 long ProviderId { get; set; }
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public decimal Price { get; set; }
|
public decimal Rate { get; set; }
|
||||||
public Currency Currency { get; set; }
|
public Currency Currency { get; set; }
|
||||||
public bool Active { get; set; }
|
public bool Active { get; set; }
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ public class CreateEnergyRateCommandHandler(EnergyService energyService) : IComm
|
|||||||
{
|
{
|
||||||
ProviderId = command.ProviderId,
|
ProviderId = command.ProviderId,
|
||||||
Name = command.Name,
|
Name = command.Name,
|
||||||
Price = command.Price,
|
Rate = command.Rate,
|
||||||
Currency = command.Currency,
|
Currency = command.Currency,
|
||||||
Active = command.Active
|
Active = command.Active
|
||||||
},cancellationToken);
|
},cancellationToken);
|
||||||
@ -46,7 +46,7 @@ public class CreateEnergyRateCommandValidator : AbstractValidator<CreateEnergyRa
|
|||||||
return false == nameInUse;
|
return false == nameInUse;
|
||||||
})
|
})
|
||||||
.WithMessage("This Name is already in use by another energy rate.");
|
.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)
|
RuleFor(command => command.ProviderId)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.SetValidator(new DbEntityExistValidator<EnergyProvider,long>(dbContext))
|
.SetValidator(new DbEntityExistValidator<EnergyProvider,long>(dbContext))
|
||||||
|
@ -29,7 +29,7 @@ public class EnergyService(CHDbContext dbContext)
|
|||||||
{
|
{
|
||||||
Name = options.Name,
|
Name = options.Name,
|
||||||
Currency = options.Currency,
|
Currency = options.Currency,
|
||||||
Price = options.Price,
|
Rate = options.Rate,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
Provider = provider,
|
Provider = provider,
|
||||||
Active = options.Active
|
Active = options.Active
|
||||||
@ -82,7 +82,7 @@ public class EnergyService(CHDbContext dbContext)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (options.Rate.HasValue)
|
if (options.Rate.HasValue)
|
||||||
energyRate.Price = 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;
|
||||||
@ -91,7 +91,7 @@ public class EnergyService(CHDbContext dbContext)
|
|||||||
}
|
}
|
||||||
public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken)
|
public async Task UpdateEnergyRateAsync(UpdateEnergyRateCommandOptions options, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (options.StartedAt.HasValue)
|
if (options.StartedAt > DateTime.UtcNow)
|
||||||
{
|
{
|
||||||
var energyRateUpdate = new EnergyRateUpdate
|
var energyRateUpdate = new EnergyRateUpdate
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ public class CreateEnergyRateCommandOptions
|
|||||||
{
|
{
|
||||||
public long ProviderId { get; set; }
|
public long ProviderId { get; set; }
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public decimal? Price { get; set; }
|
public decimal? Rate { get; set; }
|
||||||
public Currency Currency { get; set; }
|
public Currency Currency { get; set; }
|
||||||
public bool Active { get; set; }
|
public bool Active { get; set; }
|
||||||
}
|
}
|
@ -72,8 +72,8 @@ public partial class CHDbScaffoldedContext : DbContext
|
|||||||
entity.Property(e => e.Name)
|
entity.Property(e => e.Name)
|
||||||
.HasMaxLength(255)
|
.HasMaxLength(255)
|
||||||
.HasColumnName("name");
|
.HasColumnName("name");
|
||||||
entity.Property(e => e.Price).HasColumnName("price");
|
|
||||||
entity.Property(e => e.ProviderId).HasColumnName("provider_id");
|
entity.Property(e => e.ProviderId).HasColumnName("provider_id");
|
||||||
|
entity.Property(e => e.Rate).HasColumnName("rate");
|
||||||
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
|
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
|
||||||
|
|
||||||
entity.HasOne(d => d.Provider).WithMany(p => p.EnergyRates)
|
entity.HasOne(d => d.Provider).WithMany(p => p.EnergyRates)
|
||||||
|
@ -11,7 +11,7 @@ public partial class EnergyRate
|
|||||||
|
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
public decimal? Price { get; set; }
|
public decimal? Rate { get; set; }
|
||||||
|
|
||||||
public bool Active { get; set; }
|
public bool Active { get; set; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user