/// <summary> /// updates the stock of a product to 20 if the stock is less than 20 /// </summary> /// <param name="productID"></param> public void ProcessOwnerInventory(int productID) { //get the product var product = _ownerInventory.Find(item => item.ProductID == productID); //validate that the product is valid if (product != null) { //check that the stock level is below max if (product.StockLevel < Constants.OWNERMAXSTOCK) { var oiRepo = new OwnerInventoryRepository(); try { //update the product product = oiRepo.UpdateOwnerInventory(product.ProductID, Constants.OWNERMAXSTOCK); } catch (Exception) { throw; } Console.WriteLine(product.ProductID + " stocklevel has been reset to " + product.StockLevel); } else { WidgetError.DisplayError(product.Name + " already has enough stock"); } } else { WidgetError.DisplayError("No such product found"); } }