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 @@
+ +