Bondarenko M.S. Lab Work 3 hard #13

Closed
maxnes3 wants to merge 8 commits from LabWork_03_hard into LabWork_02_hard
Showing only changes of commit 77e1d7924f - Show all commits

View File

@ -65,27 +65,15 @@ namespace ComputersShopDataBaseImplement.Implements
public OrderViewModel? Insert(OrderBindingModel model)
{
var newOrder = Order.Create(model);
try
if (newOrder == null)
{
if (newOrder == null)
{
return null;
}
using var context = new ComputersShopDataBase();
context.Orders.Add(newOrder);
context.SaveChanges();
}
catch (DbUpdateException ex)
{
var innerException = ex.InnerException;
while (innerException != null)
{
Console.WriteLine(innerException.Message);
innerException = innerException.InnerException;
}
return null;
}
using var context = new ComputersShopDataBase();
context.Orders.Add(newOrder);
context.SaveChanges();
return GetViewModel(newOrder);
}