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 EquipmentReceivingController : Controller { private readonly ILogger _logger; private readonly IEquipmentReceivingLogic _equipmentReceiving; public EquipmentReceivingController(ILogger logger, IEquipmentReceivingLogic equipmentReceiving) { _logger = logger; _equipmentReceiving = equipmentReceiving; } [HttpGet] public List? GetReceivingList() { try { return _equipmentReceiving.ReadList(null); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка компонентов"); throw; } } [HttpGet] public List? GetReceivings(int clientId) { try { return _equipmentReceiving.ReadList(new EquipmentReceivingSearchModel { ClientId = clientId }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка получения списка получений клиента id ={ Id}", clientId); throw; } } [HttpPost] public void CreateReceiving(EquipmentReceivingBindingModel model) { try { _equipmentReceiving.Create(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка создания получения"); throw; } } } }