using ComputerShopContracts.BindingModels; using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.SearchModels; using ComputerShopContracts.ViewModels; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace ComputerShopRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class SupplyController : Controller { private readonly ILogger _logger; private readonly ISupplyLogic _supply; private readonly IOrderLogic _order; public SupplyController(ILogger logger, ISupplyLogic supply, IOrderLogic order) { _logger = logger; _supply = supply; _order = order; } /* [HttpGet] public List? GetAssemblyList(int clientId) { try { return _supply.ReadList(new SupplySearchModel { }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка сборок"); throw; } } [HttpGet] public Tuple>>? GetAssembly(int assemblyId) { try { var elem = _supply.ReadElement(new SupplySearchModel { Id = assemblyId }); if (elem == null) return null; return Tuple.Create(elem, elem.AssemblyComponents.Select(x => Tuple.Create(x.Value.Item1.ComponentName, x.Value.Item2)).ToList()); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения сборки по id={Id}", assemblyId); throw; } } [HttpGet] public List? GetComponentList() { try { return _component.ReadList(null); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка компонентов"); throw; } } [HttpPost] public void CreateAssembly(AssemblyBindingModel model) { try { _assembly.Create(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания сборки"); throw; } } [HttpPost] public void DeleteAssembly(AssemblyBindingModel model) { try { _assembly.Delete(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления сборки"); throw; } } [HttpPost] public void AddComponentToAssembly(Tuple model) { try { _assembly.AddComponentToAssembly(model.Item1, model.Item2, model.Item3); } catch (Exception ex) { _logger.LogError(ex, "Ошибка добавления компонента в сборку."); throw; } } [HttpPost] public void EditAssembly(AssemblyBindingModel model) { try { _assembly.Update(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка удаления сборки"); throw; } } */ } }