//Focus: How to create & persist order information? public void CreateOrder() { User UserSelect = ValidateUser(); Location LocationSelect = SelectLocation(); Console.WriteLine("Welcome. Let's start by creating an order.\n" + "Type Add to add more pizzas. Type Finish to complete order."); OrderEntity order = new OrderEntity(); string input = Console.ReadLine(); while (input == "Add") { PizzaEntity tempPizza = new PizzaEntity(); //Step 1: What kind of pizza to order??? StorePizzaDefinition tempPizzaName = SelectPizzaType(); //Step 2: Make the pizza. Crust tempCrust = SelectCrust(); Size tempSize = SelectSize(); List <Topping> tempTopping = CreateToppingList(); //Step 3: Choose the quantity. Console.WriteLine("How many pizzas do you want?"); string QuantityChoice = Console.ReadLine(); //Step 4: Map the information into the pizza entity. tempPizza.Name = tempPizzaName.Name; tempPizza.Price = tempPizzaName.Price; tempPizza.Quantity = Int32.Parse(QuantityChoice); tempPizza.PizzaCrust = tempCrust; tempPizza.PizzaSize = tempSize; tempPizza.PizzaTopping = tempTopping; //Step 5: Add the pizza entity to order. order.PizzaList.Add(tempPizza); Console.WriteLine("Would you like to make another pizza?\n" + "As a reminder, type Add to add another pizza. Type Finish to complete order."); string UserDecision = Console.ReadLine(); if (UserDecision == "Finish") { break; } } //Final steps: Add user/location info to order and submit order. order.UserInfo = UserSelect; order.LocationIdentifier = LocationSelect; order.OrderDate = DateTime.Today; _db.OrderList.Add(order); _db.SaveChanges(); }
public StorePizzaDefinition SelectPizzaType() { Console.WriteLine("Select the type of pizza you want to make. Type in name of pizza to select pizzatype."); foreach (var PizzaDef in _db.PizzaDefinition) { Console.WriteLine($"{PizzaDef.Name}: {PizzaDef.Price}"); } string PizzaType = Console.ReadLine(); StorePizzaDefinition SelectPizza = _db.PizzaDefinition.FirstOrDefault(pt => pt.Name == PizzaType); return(SelectPizza); }