Contracktor: rest api main controller

This commit is contained in:
Safgerd 2023-05-19 16:53:00 +04:00
parent 2a1d3bb6fa
commit a05aede159

View File

@ -244,9 +244,77 @@ namespace ComputerStoreRestAPI.Controllers
} }
#region Consignment
[HttpGet]
public List<ConsignmentViewModel>? 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 #region Request
[HttpGet] [HttpGet]
@ -320,8 +388,6 @@ namespace ComputerStoreRestAPI.Controllers
} }
#endregion #endregion
#region Order #region Order
[HttpGet] [HttpGet]
public List<OrderViewModel>? GetOrdersList() public List<OrderViewModel>? 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] [HttpPatch]
public bool UpdateOrderInProcess(OrderBindingModel order) public bool UpdateOrderInProcess(OrderBindingModel order)
{ {