diff --git a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs index f80844e..3eefb25 100644 --- a/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs +++ b/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Order.cs @@ -87,11 +87,12 @@ namespace ElectronicsShopDataBaseImplement.Models context.SaveChanges(); } var order = context.Orders.First(x => x.ID == model.ID); + order.Sum = model.Sum; foreach (var op in model.ProductList) { context.OrderProducts.Add(new OrderProduct { _order = order, _product = context.Products.First(x => x.ID == op.Key), - Count = op.Value.Item2 + Count = op.Value.Item2, }); context.SaveChanges(); } diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs index 4940f28..260e37f 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs @@ -161,7 +161,7 @@ namespace ElectronicsShopRestAPI.Controllers { ClientID = view.ClientID, DateCreate = view.DateCreate, ProductList = _productlist, - //sum + Sum = Calc(_productlist) }; var operationResult = _order.Update(model); if (!operationResult) { @@ -198,8 +198,8 @@ namespace ElectronicsShopRestAPI.Controllers { ID = _orderId, ClientID = view.ClientID, DateCreate = view.DateCreate, - ProductList = _productlist - //sum + ProductList = _productlist, + Sum = Calc(_productlist) }; var operationResult = _order.DeleteProduct(model); if (!operationResult) { @@ -211,5 +211,14 @@ namespace ElectronicsShopRestAPI.Controllers { throw; } } + + [HttpPost] + public double Calc(Dictionary _productlist) { + double ans = 0; + foreach (var item in _productlist) { + ans += item.Value.Item1.Price * item.Value.Item2; + } + return ans; + } } } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml index 0e523e9..fa75e9a 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml @@ -75,7 +75,7 @@
diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml index b8f6b52..717fadf 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml @@ -76,7 +76,7 @@
diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml index a2bd948..23f23eb 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Shared/_Layout.cshtml @@ -12,7 +12,7 @@