From e01d07602596dd4a94d9c4338b9c6dc1f2ea540d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Fri, 24 Mar 2023 15:22:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FoodOrders/FoodOrders/FormMain.cs | 7 +------ .../Implements/OrderStorage.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FoodOrders/FoodOrders/FormMain.cs b/FoodOrders/FoodOrders/FormMain.cs index 03c14c5..36333bb 100644 --- a/FoodOrders/FoodOrders/FormMain.cs +++ b/FoodOrders/FoodOrders/FormMain.cs @@ -72,12 +72,7 @@ namespace FoodOrdersView { var operationResult = _logicO.TakeOrderInWork(new OrderBindingModel { - Id = id, - DishId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DishId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()), + Id = id }); if (!operationResult) { diff --git a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs index 17de902..b7ec262 100644 --- a/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs +++ b/FoodOrders/FoodOrdersDatabaseImplement/Implements/OrderStorage.cs @@ -55,7 +55,10 @@ namespace FoodOrdersDatabaseImplement.Implements using var context = new FoodOrdersDatabase(); context.Orders.Add(newOrder); context.SaveChanges(); - return newOrder.GetViewModel; + return context.Orders + .Include(x => x.Dish) + .FirstOrDefault(x => x.Id == newOrder.Id) + ?.GetViewModel; } public OrderViewModel? Update(OrderBindingModel model) @@ -68,7 +71,10 @@ namespace FoodOrdersDatabaseImplement.Implements } order.Update(model); context.SaveChanges(); - return order.GetViewModel; + return context.Orders + .Include(x => x.Dish) + .FirstOrDefault(x => x.Id == order.Id) + ?.GetViewModel; } public OrderViewModel? Delete(OrderBindingModel model) {