Удаление продуктов

This commit is contained in:
Алексей Тихоненков 2024-08-27 04:11:09 +04:00
parent 083b08ae7c
commit fdbf098a6e
2 changed files with 28 additions and 5 deletions

View File

@ -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<List<ProductViewModel>>($"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()
{

View File

@ -1,22 +1,22 @@
@{
ViewData["Title"] = "DeleteRoom";
ViewData["Title"] = "DeleteProduct";
}
<head>
<link rel="stylesheet" href="~/css/style.css" asp-append-version="true" />
</head>
<div class="text-center">
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Удалить комнату</h2>
<h2 class="u-text u-text-custom-color-1 u-text-default u-text-1"> Удалить блюдо</h2>
</div>
<form method="post">
<div class="spisok">
<label class="u-label u-text-custom-color-1 u-label-1">Комната: </label>
<select id="room" name="room" class="form-control" asp-items="@(new SelectList(@ViewBag.Rooms, "Id", "RoomNumber"))"></select>
<label class="u-label u-text-custom-color-1 u-label-1">Блюдо: </label>
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products, "Id", "ProductName"))"></select>
</div>
<div class="button">
<button type="submit" class="button-action">Удалить</button>
</div>
<div class="button">
<a asp-area="" asp-controller="Home" asp-action="Rooms" class="button-action">Назад</a>
<a asp-area="" asp-controller="Home" asp-action="Products" class="button-action">Назад</a>
</div>
</form>