Quota: fix

This commit is contained in:
pavelbannov 2022-10-19 19:27:04 +03:00
parent a703b09b63
commit 35592fd306

View File

@ -724,20 +724,30 @@ public class TariffService : ITariffService
CreateOn = DateTime.UtcNow
};
efTariff.CustomerId = efTariff.CustomerId == null ? "" : efTariff.CustomerId;
if (efTariff.Id == default)
{
efTariff.Id = (-tenant);
}
if (efTariff.CustomerId == default)
{
efTariff.CustomerId = "";
}
efTariff = dbContext.AddOrUpdate(r => r.Tariffs, efTariff);
dbContext.SaveChanges();
var tariffRows = tariffInfo.Quotas.Select(q => new DbTariffRow
foreach (var q in tariffInfo.Quotas)
{
dbContext.AddOrUpdate(r => r.TariffRows, new DbTariffRow
{
TariffId = efTariff.Id,
Quota = q.Id,
Quantity = q.Quantity,
Tenant = tenant
});
}
dbContext.TariffRows.AddRange(tariffRows);
dbContext.SaveChanges();
inserted = true;