//this function accepts the product selected by the user and the quantity, retrieves the selected product from the product list, and adds //it to a new order list to be used throughout the order public List <OrderList> BuildOrderList(int userInput, int quantity) { var productIndex = userInput - 1; var listOfProducts = Catalog.GetProducts(); foreach (var product in listOfProducts) { if (listOfProducts.IndexOf(product) == productIndex) { orderList.Add(new OrderList(product.Category, product.Name, product.Price, quantity, (quantity * product.Price), product.Description)); } } return(orderList); }
//this function uses an instance of the ProductList class and displays the product list for user selection public void DisplayProductMenu() { var productList = new ProductList(); var listOfProducts = productList.GetProducts(); if (listOfProducts.Count > 0) { Console.WriteLine(LIST_FORMAT, "", "Category", "Name", "Price", "Description"); Console.WriteLine(""); foreach (var item in listOfProducts) { Console.WriteLine(LIST_FORMAT, (listOfProducts.IndexOf(item) + 1), item.Category, item.Name, item.Price.ToString("C"), item.Description); } } }