public static void DisplayOrders(List <Porder> orders) { Console.WriteLine("--------------------------------------"); int menucount = 1; for (int i = 0; i <= orders.Count - 1; menucount++, i++) { Console.WriteLine($"Order: {menucount}"); Console.WriteLine("----------------"); Console.WriteLine(orders[i].PUserId); // Puser user = UserHandler.GetUser(orders[i].PUserId + ""); // Console.WriteLine($" Location: {user.Location}"); Console.WriteLine($" Order Date: {orders[i].PDate}"); Console.WriteLine($" Order Time: {orders[i].PTime}"); Pizza pizza = PizzaHandler.GetPizza(orders[i].PizzaId); Console.WriteLine($" Pizza Type: {pizza.PType}"); Console.WriteLine($" Pizza Size: {pizza.PSize}"); Console.WriteLine($" Pizza Crust: {pizza.Crust}"); Console.WriteLine($" ORDER PRICE: {orders[i].OrderCost}"); } }
private void CustomerPizzas() { //Check for pizza Count bool pizzaCountValid; do { numPizza = base.ValidateIntegerOption(base.GetInput("How many pizzas would you like to buy ? ")); pizzaCountValid = PizzaHandler.validatePizzaCount(ref maxPizza, numPizza); if (pizzaCountValid == false) { Console.WriteLine("You can't Order more than 100 pizzas"); } } while (numPizza > maxPizza); pizzas = PizzaHandler.GetPizzasFromLocation(locations[index - 1]); }
public void CustomerOrder() { orders = new List <Porder>(); //Iterate base on pizza count for (int i = 1; i <= numPizza; i++) { if (OrderHandler.validateCurrentCost(currentCost)) { Console.WriteLine("Choose from the List of Pizzas: "); PizzaView.DisplayPizzas(pizzas); do //this code is a repetitive code. create a method for it { Console.WriteLine(); index = base.GetValidatedOption(pizzas.Count); } while (index == -1); Console.WriteLine(); //Get the pizza from the list Pizza pizza = pizzas[index - 1]; Console.WriteLine("You chose this Pizza from the menu"); PizzaView.DisplayPizza(pizza); Console.WriteLine(); Console.WriteLine("Choose from the List of Pizza sizes below"); Console.WriteLine(); string[] pizzaSizes = PizzaHandler.pizzaSize; PizzaView.DisplaySize(pizzaSizes); do { Console.WriteLine(); index = base.GetValidatedOption(pizzaSizes.Length); } while (index == -1); string pizzaSize = pizzaSizes[index - 1]; //Size of the pizza Console.WriteLine(); Console.WriteLine($"You chose [{pizzaSizes[index - 1]}] from the list of sizes"); Console.WriteLine(); Console.WriteLine("Choose from the List of Pizza Crust below"); Console.WriteLine(); string[] pizzaCrusts = PizzaHandler.pizzaCrust; PizzaView.DisplayCrust(pizzaCrusts); do { Console.WriteLine(); index = base.GetValidatedOption(pizzaCrusts.Length); } while (index == -1); string pizzaCrust = pizzaCrusts[index - 1]; Console.WriteLine(); Console.WriteLine($"You chose [{pizzaCrust[index - 1]}] from the list of Crust"); Console.WriteLine(); chosenToppings = new List <Toppings>(); Console.WriteLine("Choose from the Toppings on the List:"); List <Toppings> toppings = ToppingsHandler.GetToppings(pizza); ToppingView.DisplayToppings(toppings); Console.WriteLine(); List <Toppings> defaultToppings = ToppingsHandler.GetDefaultToppings(pizza); ToppingView.DisplayDefaultToppings(defaultToppings); Console.WriteLine(); //Check for Toppings Count int numToppings, maxToppings = 0; bool toppingCountValid; do { numToppings = base.ValidateIntegerOption(base.GetInput("How many Toppings would you like on yout Pizza ? ")); toppingCountValid = ToppingsHandler.validateToppingsCount(ref maxToppings, numToppings); if (toppingCountValid == false) { Console.WriteLine("You can't have more than Five(5) toppings on your pizza"); } } while (numPizza > maxPizza); for (int t = 1; t <= numToppings; t++) { do { index = base.GetValidatedOption(toppings.Count); } while (index == -1); chosenToppings.Add(toppings[index - 1]); } //Re assign chosen topping when the default toppings has been added chosenToppings = ToppingsHandler.AddDefaultToChosenToppings(chosenToppings, defaultToppings); //Add Default to Chosen ToppingView.DisplayToppings(chosenToppings); double toppingsCost = ToppingsHandler.TotalToppingsCost(chosenToppings); ToppingView.DisplayToppingsTotalCost(toppingsCost); //problem is in the PizzaHandler class Pizza pizzaOrder = PizzaHandler.GetPizzaPrice(pizza.PType, pizzaSize, pizzaCrust); Console.WriteLine("Pizza Order: " + pizzaOrder); // currentCost = OrderHandler.GetOrderCost(Convert.ToDouble(pizzaOrder.PPrice), toppingsCost); OrderView.DisplayOrderCost(currentCost); totalCost += currentCost; orders.Add(new Porder { PDate = DateTime.Now.ToString("M/d/yyyy"), PTime = DateTime.Now.ToShortTimeString(), OrderCost = Convert.ToString(currentCost), PizzaId = pizzaOrder.PizzaId, PUserId = user.PUserId, CLocationId = location.LocationId }); } else { Console.WriteLine("You cant order more than 5000 pizza cost"); displayView(user); } } OrderView.DisplayTotalOrderCost(totalCost); Console.WriteLine(); string orderOption; do { orderOption = base.GetInput("Are you sure about your Order ?. Type in YES to accept or NO to decline "); if (orderOption.ToLower().Equals("yes")) { bool inserted = OrderHandler.InsertOrders(orders); if (inserted == true) { Console.WriteLine(" Yay! Your Order has been placed "); Console.WriteLine("Thank you for choosing PizaBox"); Environment.Exit(0); } else { Console.WriteLine(" Something went wrong with your order: Pls try re-ordering "); displayView(user); } } else if (orderOption.ToLower().Equals("no")) { Console.WriteLine("Thank you for choosing PizaBox"); Environment.Exit(0); } else { Console.WriteLine("Incorrect Option, pls try again."); Console.WriteLine(); } } while (orderOption.ToLower().Equals("yes") || orderOption.ToLower().Equals("no")); }
public void displayView(Puser user) { this.user = user; Console.WriteLine("===================== ADMINISTRATOR =================="); Console.WriteLine(); Console.WriteLine($"Choose from the options below from 1 to {menuAdmin.Length}"); Console.WriteLine(); int listCount = 1; int option; for (int i = 0; i < menuAdmin.Length - 1; listCount++, i++) { Console.WriteLine($" ({listCount}) \t {menuAdmin[i]}"); } Console.WriteLine(); do { option = base.GetValidatedOption(menuAdmin.Length - 1); } while (option == -1); //Load Locations from domainusing List <Plocation> locations = LocationHandler.GetLocationData(); switch (option - 1) { case (int)menuAdminConst.Stores: { LocationView.DisplayLocationsOptions(locations); break; } case (int)menuAdminConst.Pizzas: { LocationView.DisplayLocationsOptions(locations); do { option = base.GetValidatedOption(locations.Count - 1); } while (option == -1); //Load Pizzas from domain List <Pizza> pizzas = PizzaHandler.GetPizzasFromLocation(locations[option - 1]); //Display pizzas PizzaView.DisplayPizzas(pizzas); break; } case (int)menuAdminConst.Order: { List <Porder> orders = OrderHandler.GetOrders(); OrderView.DisplayOrders(orders); break; } case (int)menuAdminConst.Customer: { List <Customer> customers = CustomerHandler.GetCustomers(); CustomerDetailsView.DisplayCustomerDetails(customers); break; } case (int)menuAdminConst.Sales: { break; } case (int)menuAdminConst.Users: { List <Puser> users = UserHandler.GetUsers(); UserDetailsView.DisplayUserDetails(users); break; } } string option1; do { option1 = base.GetInput("Type in YES to continue or NO to quit. "); if (option1.ToLower().Equals("yes")) { displayView(user); } else if (option1.ToLower().Equals("no")) { Console.WriteLine("Thank you for choosing PizaBox"); Environment.Exit(0); } else { Console.WriteLine("Incorrect Option, pls try again."); Console.WriteLine(); } } while (option1.ToLower().Equals("yes") || option1.ToLower().Equals("no")); Console.WriteLine(); }