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 @@