using ComputerShopContracts.BindingModels; using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace ComputerShopRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class AssemblyController : Controller { private readonly ILogger _logger; private readonly IAssemblyLogic _assembly; private readonly IComponentLogic _component; public AssemblyController(ILogger logger, IAssemblyLogic assembly, IComponentLogic component) { _logger = logger; _assembly = assembly; _component = component; } [HttpGet] public List? GetAssemblyList() { try { return _assembly.ReadList(null); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка сборок"); 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; } } } }