DASHA SPASIBO CHTO ZALILA
This commit is contained in:
parent
6f449c505b
commit
b48124b0b9
@ -10,8 +10,8 @@ namespace HardwareShopDatabaseImplement
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store1;Username=user;Password=12345");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store4;Username=postgres;Password=1234");
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
@ -4,6 +4,7 @@ using HardwareShopContracts.StoragesContracts;
|
||||
using HardwareShopContracts.ViewModels;
|
||||
using HardwareShopDatabaseImplement.Models.Storekeeper;
|
||||
using HardwareShopDatabaseImplement.Models.Worker;
|
||||
using HardwareShopDataModels.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
@ -116,7 +117,17 @@ namespace HardwareShopDatabaseImplement.Implements.Worker
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Builds.Remove(element);
|
||||
var buildPurchases = context.PurchasesBuilds.Where(x => x.BuildId == element.Id).ToList();
|
||||
buildPurchases.ForEach(x =>
|
||||
{
|
||||
var purchase = context.Purchases.Include(x => x.Builds).FirstOrDefault(rec => rec.Id == x.PurchaseId && rec.PurchaseStatus != PurchaseStatus.Выдан);
|
||||
if (purchase != null)
|
||||
{
|
||||
purchase.Sum -= element.Price * x.Count;
|
||||
purchase.Sum = Math.Round(purchase.Sum, 2);
|
||||
}
|
||||
});
|
||||
context.Builds.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user