diff --git a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs index fbff0dc..86e8337 100644 --- a/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs +++ b/ComputerShopProvider/ComputerShopRestApi/Controllers/OrderController.cs @@ -4,6 +4,7 @@ using ComputerShopContracts.SearchModels; using ComputerShopContracts.ViewModels; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using System.Reflection; namespace ComputerShopRestApi.Controllers { @@ -13,13 +14,11 @@ namespace ComputerShopRestApi.Controllers { private readonly ILogger _logger; private readonly IOrderLogic _order; - private readonly ISupplyLogic _supply; public OrderController(ILogger logger, IOrderLogic order, ISupplyLogic supply) { _logger = logger; _order = order; - _supply = supply; } [HttpGet] @@ -36,19 +35,6 @@ namespace ComputerShopRestApi.Controllers throw; } } - [HttpGet] - public List? GetSuppliesList() - { - try - { - return _supply.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка компонентов"); - throw; - } - } [HttpGet] public List? GetOrders(int clientId) @@ -90,5 +76,19 @@ namespace ComputerShopRestApi.Controllers throw; } } - } + + [HttpPost] + public void AddAssembly(Tuple model) + { + try + { + _order.AddAssembly(model.Item1, model.Item2, model.Item3); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка добавления компонента в сборку."); + throw; + } + } + } } diff --git a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs index d5f15cb..9986b2c 100644 --- a/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs +++ b/ComputerShopProvider/OrdererClientApp/Controllers/HomeController.cs @@ -220,13 +220,13 @@ namespace OrdererClientApp.Controllers } [HttpPost] - public void AddAssemblyToOrder(int order, int assembly, int amount) + public void AddAssembly(int order, int assembly, int amount) { if (APIClient.Client == null) { throw new Exception("Необходима авторизация"); } - APIClient.PostRequest("api/order/AddAssemblyToOrder", Tuple.Create( + APIClient.PostRequest("api/order/AddAssembly", Tuple.Create( new AssemblySearchModel() { Id = assembly }, new OrderSearchModel() { Id = order }, diff --git a/ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml b/ComputerShopProvider/OrdererClientApp/Views/Home/AddAssembly.cshtml similarity index 100% rename from ComputerShopProvider/OrdererClientApp/Views/Home/AddAssemblyToOrder.cshtml rename to ComputerShopProvider/OrdererClientApp/Views/Home/AddAssembly.cshtml