From 413769587689f8d04d25bc5a531737137df7c755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=A4=D0=B5=D0=B4=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Fri, 26 Jul 2024 16:01:31 +0400 Subject: [PATCH] Edit order fix --- .../ElectronicsShopShopClientApp/APIClient.cs | 3 +++ .../Controllers/HomeController.cs | 18 ++++++++---------- .../Views/Home/AddProduct.cshtml | 2 ++ .../Views/Home/EditOrder.cshtml | 2 +- .../Views/Home/OrderView.cshtml | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/APIClient.cs b/ElectronicsShop/ElectronicsShopShopClientApp/APIClient.cs index e7d75d4..032d4a6 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/APIClient.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/APIClient.cs @@ -11,8 +11,11 @@ namespace ElectronicsShopUserApp { public static ClientViewModel? Client { get; set; } = null; + public static string port { get; set; } = string.Empty; + public static void Connect(IConfiguration configuration) { _client.BaseAddress = new Uri(configuration["IPAddress"]); + port = _client.BaseAddress.Port.ToString(); _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs index ad53d77..b86ee6c 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Controllers/HomeController.cs @@ -199,25 +199,23 @@ namespace ElectronicsShopUserApp.Controllers { ?? throw new Exception("Îøèáêà ïîëó÷åíèÿ ìîäåëè"); APIClient.PostRequestStr($"api/main/deleteproductorder", view.ID, id); - return RedirectToAction("OrderView"); + return Redirect($"https://localhost:7219/Home/EditOrder/{view.ID}"); } [HttpGet] - public IActionResult AddProduct() { + public IActionResult AddProduct(int id) { ViewBag.Products = APIClient.GetRequset>($"api/main/getproducts"); - return View(); + return View(id); } [HttpPost] - public void AddProduct(int product, int count) { + public void AddProduct(int product, int count, int id) { var _product = APIClient.GetRequset($"api/main/getproduct?_productid={product}") ?? throw new Exception("Îøèáêà ïîëó÷åíèÿ òîâàðà"); - var _order = APIClient.GetRequset($"api/main/getorder?_clientid={APIClient.Client?.ID}") - ?? throw new Exception("Îøèáêà ïîëó÷åíèÿ çàêàçà"); - - APIClient.ListPostRequest($"api/main/addproduct", _product, count, _order.ID); - Response.Redirect("OrderView"); - } + APIClient.ListPostRequest($"api/main/addproduct", _product, count, id); + // ÿ íå çíàþ êàê òóò åùå íîðìàëüíî ñäåëàòü + Response.Redirect($"https://localhost:7219/Home/EditOrder/{id}"); + } [HttpGet] public IActionResult Payment(int id) { diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml index 32dfa0d..b2668ba 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/AddProduct.cshtml @@ -1,10 +1,12 @@ @{ ViewData["Title"] = "AddProduct"; } +@model int

Добавить товар

+
Продукты:
diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml index 7540af1..a60e775 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/EditOrder.cshtml @@ -28,7 +28,7 @@

- Добавить товар + Добавить товар

diff --git a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml index 106a818..335529f 100644 --- a/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml +++ b/ElectronicsShop/ElectronicsShopShopClientApp/Views/Home/OrderView.cshtml @@ -28,7 +28,7 @@

- Добавить товар + Добавить товар