From a05aede159c471e574b50c0a6ca415e80fa26394 Mon Sep 17 00:00:00 2001 From: Safgerd Date: Fri, 19 May 2023 16:53:00 +0400 Subject: [PATCH] Contracktor: rest api main controller --- .../Controllers/MainController.cs | 112 +++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/ComputerStoreRestAPI/Controllers/MainController.cs b/ComputerStoreRestAPI/Controllers/MainController.cs index 948c9b4..48c1185 100644 --- a/ComputerStoreRestAPI/Controllers/MainController.cs +++ b/ComputerStoreRestAPI/Controllers/MainController.cs @@ -244,9 +244,77 @@ namespace ComputerStoreRestAPI.Controllers } + #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] @@ -320,8 +388,6 @@ namespace ComputerStoreRestAPI.Controllers } #endregion - - #region Order [HttpGet] public List? GetOrdersList() @@ -337,6 +403,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) {