From 1774b0c75816347e9aaaf900612c619ac869573c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Tue, 16 May 2023 10:40:26 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/BuildController.cs | 4 +-- .../Controllers/HomeController.cs | 29 +++++++++++++++++-- .../Views/Home/Builds.cshtml | 27 +++++++++++++++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/HardwareShop/HardwareShopRestApi/Controllers/BuildController.cs b/HardwareShop/HardwareShopRestApi/Controllers/BuildController.cs index 9a70f32..cf31464 100644 --- a/HardwareShop/HardwareShopRestApi/Controllers/BuildController.cs +++ b/HardwareShop/HardwareShopRestApi/Controllers/BuildController.cs @@ -43,11 +43,11 @@ namespace HardwareShopRestApi.Controllers } [HttpGet] - public BuildViewModel? GetBuild(int id) + public BuildViewModel? GetBuild(int buildId) { try { - return _buildLogic.ReadElement(new() { Id = id }); + return _buildLogic.ReadElement(new() { Id = buildId }); } catch (Exception ex) { diff --git a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs index 647baad..797ca14 100644 --- a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using HardwareShopContracts.BindingModels; +using HardwareShopContracts.SearchModels; using HardwareShopContracts.ViewModels; using HardwareShopDatabaseImplement.Models; using HardwareShopDataModels.Enums; @@ -99,8 +100,27 @@ namespace HardwareShopWorkerApp.Controllers Response.Redirect("Builds"); } + [HttpGet] + public BuildViewModel GetBuild(int buildId) + { + if (APIClient.User == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (buildId <= 0) + { + throw new Exception($"Идентификтаор сборки не может быть ниже или равен 0"); + } + var result = APIClient.GetRequest($"api/build/getBuild?buildId={buildId}"); + if (result == null) + { + return null; + } + return result; + } + [HttpPost] - public void UpdateBuild(string name) + public void UpdateBuild(string name, int buildId) { if (APIClient.User == null) { @@ -108,10 +128,15 @@ namespace HardwareShopWorkerApp.Controllers } if (string.IsNullOrEmpty(name)) { - throw new Exception($"Имя магазина не должно быть пустым"); + throw new Exception($"Имя сборки не должно быть пустым"); + } + if (buildId <= 0) + { + throw new Exception($"Идентификтаор сборки не может быть ниже или равен 0"); } APIClient.PostRequest("api/build/update", new BuildBindingModel { + Id = buildId, BuildName = name, UserId = APIClient.User.Id }); diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml index a8f1deb..2b78b56 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml @@ -44,6 +44,9 @@ @Html.DisplayFor(modelItem => item.BuildName) + + + } @@ -83,7 +86,7 @@