public async Task <IActionResult> UpdateLineItemInStock(ILIDTO lineItemDTO) { try { var existingILIs = await _locationService.GetAllProductsAtLocationAsync(lineItemDTO.LocationId); var existingLineItem = existingILIs.Single(ili => ili.ProductId == lineItemDTO.ProductId); if (existingLineItem != null) { existingLineItem.ProductQuantity = lineItemDTO.ProductQuantity; _locationService.UpdateInventoryLineItemInRepo(existingLineItem); } return(AcceptedAtAction("UpdateLineItemInStock", lineItemDTO)); } catch (InvalidOperationException) { return(StatusCode(500)); } catch (Exception) { // TODO: Check if this is the right error code for this. return(StatusCode(500)); } }
public async Task <IActionResult> AddLineItemToStock(ILIDTO lineItemDTO) { try { var lineItem = _mapper.Map <InventoryLineItem>(lineItemDTO); _locationService.AddInventoryLineItemInRepo(lineItem); return(CreatedAtAction("AddLineItemToStock", lineItem)); } catch (Exception) { // TODO: Check if this is the right error code for this. return(StatusCode(500)); } }