From fdbf098a6e3c60179ea7edb1542c350c7ce8827f Mon Sep 17 00:00:00 2001 From: Yourdax Date: Tue, 27 Aug 2024 04:11:09 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 23 +++++++++++++++++++ .../Views/Home/DeleteProduct.cshtml | 10 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/DiningRoom/DiningRoomUserApp/Controllers/HomeController.cs b/DiningRoom/DiningRoomUserApp/Controllers/HomeController.cs index fa9280d..a423f80 100644 --- a/DiningRoom/DiningRoomUserApp/Controllers/HomeController.cs +++ b/DiningRoom/DiningRoomUserApp/Controllers/HomeController.cs @@ -228,6 +228,29 @@ namespace DiningRoomUserApp.Controllers Response.Redirect("Products"); } + public IActionResult DeleteProduct() + { + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Products = APIClient.GetRequest>($"api/main/getproductlist?userId={APIClient.User.Id}"); + return View(); + } + [HttpPost] + public void DeleteProduct(int product) + { + if (APIClient.User == null) + { + throw new Exception("Необходима авторизация"); + } + APIClient.PostRequest("api/main/deleteproduct", new ProductBindingModel + { + Id = product + }); + Response.Redirect("Products"); + } + [HttpGet] public IActionResult Privacy() { diff --git a/DiningRoom/DiningRoomUserApp/Views/Home/DeleteProduct.cshtml b/DiningRoom/DiningRoomUserApp/Views/Home/DeleteProduct.cshtml index b474fa4..081dd84 100644 --- a/DiningRoom/DiningRoomUserApp/Views/Home/DeleteProduct.cshtml +++ b/DiningRoom/DiningRoomUserApp/Views/Home/DeleteProduct.cshtml @@ -1,22 +1,22 @@ @{ - ViewData["Title"] = "DeleteRoom"; + ViewData["Title"] = "DeleteProduct"; }
-

Удалить комнату

+

Удалить блюдо

- - + +
\ No newline at end of file