From 77e1d7924f9ac6a4a3b0d96463a30652a1f83ac2 Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Tue, 28 Feb 2023 01:06:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=20=D0=BA?= =?UTF-8?q?=20=D1=81=D0=B4=D0=B0=D1=87=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/OrderStorage.cs | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs b/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs index db6ffc2..627e1ad 100644 --- a/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs @@ -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); }