готово к сдаче
This commit is contained in:
parent
f8e9e27f73
commit
77e1d7924f
@ -65,27 +65,15 @@ namespace ComputersShopDataBaseImplement.Implements
|
|||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
var newOrder = Order.Create(model);
|
var newOrder = Order.Create(model);
|
||||||
try
|
if (newOrder == null)
|
||||||
{
|
{
|
||||||
if (newOrder == null)
|
return 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using var context = new ComputersShopDataBase();
|
||||||
|
|
||||||
|
context.Orders.Add(newOrder);
|
||||||
|
context.SaveChanges();
|
||||||
return GetViewModel(newOrder);
|
return GetViewModel(newOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user