diff --git a/ComputerStoreRestAPI/Controllers/MainController.cs b/ComputerStoreRestAPI/Controllers/MainController.cs index 1fdd55e..3685687 100644 --- a/ComputerStoreRestAPI/Controllers/MainController.cs +++ b/ComputerStoreRestAPI/Controllers/MainController.cs @@ -247,13 +247,78 @@ namespace ComputerStoreRestAPI.Controllers } } - - [HttpGet] - public List GetReportConsignmentsList(ReportComponentsBindingModel model) - { - return _employeeReportLogic.GetConsignmentsByComponents(model); - } - + + #region Consignment + [HttpGet] + public List? GetConsignmentList() + { + try + { + return _consignmentLogic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Receiving list of consignment error."); + throw; + } + } + + [HttpGet] + public ConsignmentViewModel? GetConsignment(int id) + { + try + { + return _consignmentLogic.ReadElement(new ConsignmentSearchModel { ID = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Receiving consignment error."); + throw; + } + } + + [HttpDelete("{id}")] + public bool DeleteConsignment(int id) + { + try + { + return _consignmentLogic.Delete(new ConsignmentBindingModel { ID = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Removing consignment error."); + throw; + } + } + + [HttpPatch] + public bool UpdateConsignment(ConsignmentBindingModel consignment) + { + try + { + return _consignmentLogic.Update(consignment); + } + catch (Exception ex) + { + _logger.LogError(ex, "Updating consignment error."); + throw; + } + } + + [HttpPost] + public bool InsertConsignment(ConsignmentBindingModel consignment) + { + try + { + return _consignmentLogic.Create(consignment); + } + catch (Exception ex) + { + _logger.LogError(ex, "Inserting consignment error."); + throw; + } + } + #endregion #region Request [HttpGet] @@ -327,8 +392,6 @@ namespace ComputerStoreRestAPI.Controllers } #endregion - - #region Order [HttpGet] public List? GetOrdersList() @@ -344,6 +407,48 @@ namespace ComputerStoreRestAPI.Controllers } } + [HttpGet] + public OrderViewModel? GetOrder(int id) + { + try + { + return _orderLogic.ReadElement(new OrderSearchModel { ID = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Receiving order error."); + throw; + } + } + + [HttpDelete("{id}")] + public bool DeleteOrder(int id) + { + try + { + return _orderLogic.DeleteOrder(new OrderBindingModel { ID = id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Removing order error."); + throw; + } + } + + [HttpPatch] + public bool UpdateOrder(OrderBindingModel order) + { + try + { + return _orderLogic.UpdateOrder(order); + } + catch (Exception ex) + { + _logger.LogError(ex, "Updating order error."); + throw; + } + } + [HttpPatch] public bool UpdateOrderInProcess(OrderBindingModel order) {