diff --git a/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs index 0df64b1..7ea1aa2 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/StorekeeperController.cs @@ -1,5 +1,6 @@ using HardwareShopContracts.BindingModels; using HardwareShopContracts.ViewModels; +using HardwareShopDatabaseImplement.Models; using HardwareShopDataModels.Enums; using Microsoft.AspNetCore.Mvc; @@ -52,7 +53,6 @@ namespace HardwareShopStorekeeperApp.Controllers Response.Redirect("Orders"); } - [HttpPost] public void DeleteOrder(int Id) { @@ -188,7 +188,53 @@ namespace HardwareShopStorekeeperApp.Controllers } return result; } - + + [HttpPost] + public void UpdateComponent(string name, string cost, DateTime date, int component) + { + if (APIClient.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (component <= 0) + { + throw new Exception($"Идентификтаор комплектующего не может быть меньше или равен 0"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception($"Имя комплектующего не должно быть пустым"); + } + if (Convert.ToDouble(cost.Replace('.', ',')) <= 0) + { + throw new Exception($"Цена комплектующего не может быть меньше или равна 0"); + } + APIClient.PostRequest("api/component/updatedata", new ComponentBindingModel + { + Id = component, + ComponentName = name, + Cost = Convert.ToDouble(cost.Replace('.', ',')), + UserId = APIClient.User.Id, + }); + Response.Redirect("Components"); + } + + [HttpPost] + public void DeleteComponent(int component) + { + if (APIClient.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (component <= 0) + { + throw new Exception($"Идентификтаор комплектующего не может быть меньше или равен 0"); + } + APIClient.PostRequest("api/component/deletecomponent", new ComponentBindingModel + { + Id = component + }); + } + public IActionResult MainStorekeeper() { if (APIClient.User == null) diff --git a/HardwareShop/HardwareShopClientApp/Views/Shared/_Layout.cshtml b/HardwareShop/HardwareShopClientApp/Views/Shared/_Layout.cshtml index 79215e3..50dde36 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Shared/_Layout.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Shared/_Layout.cshtml @@ -7,6 +7,7 @@ +
@RenderSection("Header") diff --git a/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml b/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml index 61bc7a2..b9a3b55 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Shared/_LayoutStorekeeper.cshtml @@ -7,6 +7,7 @@ + @await RenderSectionAsync("Styles", required: false) diff --git a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml index c15c31b..1483ce3 100644 --- a/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml +++ b/HardwareShop/HardwareShopClientApp/Views/Storekeeper/Components.cshtml @@ -16,8 +16,6 @@ @{Создать комплектующее - - Привязка сборок
Дата приобретения | ++ Действия + | @@ -47,6 +48,16 @@@Html.DisplayFor(modelItem => item.DateCreate) | +
+
+
+
+
+ |
}
@@ -54,33 +65,58 @@
}
-
---|