From d196786cdea1b4c01fc2214e3d18f53ff6a78235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Wed, 29 May 2024 21:23:34 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B8=D1=83=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogic/OrderLogic.cs | 4 ++-- .../Controllers/MainController.cs | 10 ++++++++++ .../Controllers/HomeController.cs | 6 ++---- .../Views/Home/AddProduct.cshtml | 8 +++++--- .../Views/Home/CreateOrder.cshtml | 6 +++--- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/OrderLogic.cs b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/OrderLogic.cs index 6c7be8f..3c2ad25 100644 --- a/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/OrderLogic.cs +++ b/ElectronicsShop/ElectronicsShopBusinessLogic/BusinessLogic/OrderLogic.cs @@ -46,7 +46,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic if (string.IsNullOrEmpty((model.ID).ToString())) { throw new ArgumentNullException("Нет ID заказа", nameof(model.ID)); } - if (model.Sum <= 0) { + if (model.Sum <= 0) {////byda throw new ArgumentNullException("Цена зака должна быть больше 0", nameof(model.Sum)); } if (model.ClientID < 0) { @@ -59,7 +59,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic { if (model == null) throw new ArgumentNullException(nameof(model)); _logger.LogInformation($"ReadElement. ID:{model.ID}"); - var element = _storage.GetElement(model);//Не находит в бд + var element = _storage.GetElement(model); if (element == null) { _logger.LogWarning("ReadElement. elementn not found"); diff --git a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs index e8f9e22..2e08051 100644 --- a/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs +++ b/ElectronicsShop/ElectronicsShopRestAPI/Controllers/MainController.cs @@ -103,10 +103,20 @@ namespace ElectronicsShopRestAPI.Controllers { { try { + if (_order.ReadElement(new OrderSearchModel { ID = model.ID })==null) + { + CreateOrder( new OrderBindingModel + { + ClientID = model.ClientID, + ProductList = model.ProductList,//Суда поступает пустой список + Sum = model.Sum + }); + } var order=_order.ReadElement(new OrderSearchModel { ID = model.ID });//возвращает null if (model != null&& order!=null) { order.ProductList = model.ProductList; + order.Sum = model.Sum; } } catch (Exception ex) diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index b86e6f1..b845c73 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -94,7 +94,6 @@ namespace ElectronicsShopUserApp.Controllers { [HttpGet] public IActionResult CreateOrder() { ViewBag.Products = APIClient.GetRequset>("api/main/getproducts"); - return View(); } [HttpPost] @@ -107,8 +106,7 @@ namespace ElectronicsShopUserApp.Controllers { { throw new Exception(" 0"); } - - Response.Redirect("Index"); + Response.Redirect("Index"); } [HttpPost] private double CalcAll(Dictionary ProductList) @@ -121,7 +119,7 @@ namespace ElectronicsShopUserApp.Controllers { return Sum; } [HttpPost] - public double CalcProduct(int count, int product) + public double Calc(int count, int product) { var prod = APIClient.GetRequset($"api/main/getproduct?productID={product}" diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml index eecd9b7..777c895 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["Title"] = "Add Product"; + ViewData["Title"] = "AddProduct"; }

Создание заказа

@@ -34,7 +34,9 @@
+ +