LabWork03_Hard: Фиксы

This commit is contained in:
2023-04-09 21:23:18 +04:00
parent 32f0c536d1
commit 95a10df89d
2 changed files with 6 additions and 2 deletions

View File

@@ -100,6 +100,7 @@ namespace AutomobilePlantDatabaseImplement.Implements
}
car.Update(model);
car.UpdateComponents(context, model);
context.SaveChanges();
context.Database.CommitTransaction();

View File

@@ -77,14 +77,17 @@ namespace AutomobilePlantDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
var shop = context.Shops.Include(x => x.Cars).FirstOrDefault(x => x.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
context.SaveChanges();
shop.UpdateCars(context, model);
if (model.ShopCars.Count > 0)
{
shop.UpdateCars(context, model);
}
transaction.Commit();
return shop.GetViewModel;
}