Exemple #1
0
        public override void ExecuteUserChoice()
        {
            for (int i = 1; i < PossibleOptions.Count; i++)
            {
                if (selectedChoice == PossibleOptions.Count)
                {
                    return;
                    //break;
                }

                if (selectedChoice == PossibleOptions.Count - 1)
                {
                    Product newProduct = InputBrandNewProduct();
                    productService.AddNewProduct(newProduct);
                    locationService.AddInventoryLineItemInRepo(new InventoryLineItem(CurrentLocation, newProduct, 1));
                    break;
                }


                if (selectedChoice == i)
                {
                    try
                    {
                        // Add one of the new product.
                        locationService.AddInventoryLineItemInRepo(new InventoryLineItem(CurrentLocation, UnstockedProducts[i - 1], 1));
                        break;
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        Log.Error(e.Message);
                    }
                }
            }
        }
 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));
     }
 }