private static void SelectToppings(Order order, CustomPizza pizza) { //Boolean MoreToppings = false; Console.WriteLine("Do you want to add more toppings? (Y/N)"); var input = Console.ReadLine(); if (input.ToLower() == "y") { DisplayToppings(); var ToppingSelect = Console.ReadLine(); IRepository repository = Dependencies.CreateRepository(); var holder = repository.GetToppingByIndex(int.Parse(ToppingSelect)); Toppings topping = new Toppings { Name = holder.Name, Price = holder.Price, PizzaLogId = pizza.PizzaLogId, Id = holder.Id }; pizza.AddToppings(topping); order.ListOfToppings.Add(holder); order.Cost += holder.Price; } // foreach (var item in order.ListOfCrusts) // { // Console.WriteLine($"{item.Name} {item.Price}"); // } }
private static APizza SelectCustomPizza() { var pizza = new CustomPizza(); System.Console.WriteLine("Select a crust:"); PrintCrust(); var crust = SelectCrust(); System.Console.WriteLine("Select a size:"); PrintItems(_sizeSingleton.Sizes); var size = SelectSize(); var toppingCount = 0; var toppings = new List <Topping>(); System.Console.WriteLine("Select toppings:"); PrintItems(_toppingSingleton.Toppings); toppings.Add(SelectToppings()); System.Console.WriteLine("Add more toppings? (Y/N) "); var stop = Console.ReadLine(); while (stop != "n") { PrintItems(_toppingSingleton.Toppings); toppings.Add(SelectToppings()); toppingCount++; if (toppingCount == 2) { System.Console.WriteLine("You can no longer add toppings!"); break; } System.Console.WriteLine("Add another topping? (Y/N)"); stop = Console.ReadLine(); } pizza.AddCrust(crust); pizza.AddSize(size); pizza.AddToppings(toppings.ToArray()); return(pizza); }