/// <summary> /// buy more of existing products /// </summary> private void Buy() { // get the product type the user wants to buy more of Product.ProductType productType = _consoleView.DisplayBuyExistingProducut(_salesperson); int numberOfUnits = 0; // foreach loop to find the existing product foreach (Product item in _salesperson.CurrentStock) { // if product type is found it prompts the user for number of products // and adds them to the product if (item.Type == productType && productType != Product.ProductType.None) { numberOfUnits = _consoleView.GetNumberOfUnitsToBuy(); item.AddProducts(numberOfUnits); // find the product in the salesInfo list and update the number of units bought foreach (Product product in city.SalesInfo) { if (productType == product.Type) { product.BuyProducts(numberOfUnits); } } } } }