Исправление ошибки

This commit is contained in:
Володя 2023-05-11 17:50:35 +03:00
parent 2e0bf741a9
commit 88df8068a5

View File

@ -90,6 +90,7 @@ namespace AutomobilePlantDataBaseImplements.Implements
using var context = new AutoPlantDataBase();
using var transaction = context.Database.BeginTransaction();
var shops = GetFullList();
bool check = false;
try
{
foreach (var shop in shops)
@ -100,7 +101,8 @@ namespace AutomobilePlantDataBaseImplements.Implements
{
shop.Cars[car.Id] = (shop.Cars[car.Id].Item1, shop.Cars[car.Id].Item2 - quantity);
quantity = 0;
break;
check = true;
}
else
{
@ -118,6 +120,8 @@ namespace AutomobilePlantDataBaseImplements.Implements
Id = shop.Id,
Cars = shop.Cars,
});
if (check)
break;
}
}
@ -125,7 +129,12 @@ namespace AutomobilePlantDataBaseImplements.Implements
{
context.SaveChanges();
transaction.Commit();
}
else
{
transaction.Rollback();
return false;
}
}
catch