static void ModifyPizza(Apizza PizzaToModify) { PizzaToModify.Size = SelectSize().Id; PizzaToModify.Crust = SelectCrust().Id; SelectToppings(PizzaToModify); Console.WriteLine(PizzaToModify.ToString()); }
//Takes in an object and allows you to modityf a pizza static void SelectToppings(Apizza PizzaToModify) { var context = new PizzaBoxContext(); Console.WriteLine("What Toppings would you like to add"); List <Atopping> top = context.Atoppings.ToList(); foreach (var t in top) { Console.WriteLine($"{t.Id} {t.ToppingName} ${t.ToppingPrice}"); } var input = 0; do { //Takes in user input Console.WriteLine("Which Topping would you like to add\n enter 0 to leave"); int.TryParse(Console.ReadLine(), out input); int newTop = 0; //Checks to see if topping exists if (context.Atoppings.Any(p => p.Id == input)) { newTop = context.Atoppings.Where(p => p.Id == input).First().Id; } if (input != 0) { Console.WriteLine("Which Topping do you wanna change"); int.TryParse(Console.ReadLine(), out int changeTop); switch (changeTop) { case 1: PizzaToModify.Topping1 = newTop; break; case 2: PizzaToModify.Topping2 = newTop; break; case 3: PizzaToModify.Topping3 = newTop; break; case 4: PizzaToModify.Topping4 = newTop; break; case 5: PizzaToModify.Topping5 = newTop; break; default: Console.WriteLine("Pick a valid option next time!"); break; } } }while(input != 0); }
//Allows you to select a pizza static Apizza SelectPizza() { DisplayPizzas(); var context = new PizzaBoxContext(); int input = -1; do { int.TryParse(Console.ReadLine(), out input); }while(!context.Apizzas.Any(p => p.Id == input)); Apizza pizza = context.Apizzas.Where(p => p.Id == input).First(); Console.Write(pizza.PizzaName + " Selected"); pizza.Gettops(); return(pizza); }
/* * This will check the database for any item that isn't part of anything that generates * and will give it default values */ static void checkDatabase() { var context = new PizzaBoxContext(); if (!context.Astores.Any()) { var top = new Astore() { Id = 1, StoreName = "Freddys Pizza" }; context.Astores.Add(top); context.SaveChanges(); top = new Astore() { Id = 1, StoreName = "Chicago Pizza" }; context.Astores.Add(top); context.SaveChanges(); } if (!context.Atoppings.Any()) { var top = new Atopping() { ToppingName = "Cheese", ToppingPrice = 0m, Id = 1 }; context.Atoppings.Add(top); context.SaveChanges(); top = new Atopping() { ToppingName = "Peporoni", ToppingPrice = 0.5m, Id = 2 }; context.Atoppings.Add(top); context.SaveChanges(); } if (!context.Acrusts.Any()) { var top = new Acrust() { CrustName = "Thin", CrustPrice = 0m, Id = 1 }; context.Acrusts.Add(top); context.SaveChanges(); top = new Acrust() { CrustName = "Regular", CrustPrice = 0m, Id = 2 }; context.Acrusts.Add(top); context.SaveChanges(); top = new Acrust() { CrustName = "Deep Dish", CrustPrice = 1m, Id = 3 }; context.Acrusts.Add(top); context.SaveChanges(); top = new Acrust() { CrustName = "Stuff Crust", CrustPrice = 2m, Id = 4 }; context.Acrusts.Add(top); context.SaveChanges(); } if (!context.Asizes.Any()) { var top = new Asize() { SizeName = "Small", SizePrice = 0m, Id = 1 }; context.Asizes.Add(top); context.SaveChanges(); top = new Asize() { SizeName = "Medium", SizePrice = 1m, Id = 2 }; context.Asizes.Add(top); context.SaveChanges(); top = new Asize() { SizeName = "Large", SizePrice = 2m, Id = 3 }; context.Asizes.Add(top); context.SaveChanges(); } if (!context.Apizzas.Any()) { var top = new Apizza() { Id = 1, PizzaName = "Cheese Pizza", Topping1 = 1, Topping2 = 1, Size = 1, Crust = 1, Price = 10.0m }; context.Apizzas.Add(top); context.SaveChanges(); top = new Apizza() { Id = 2, PizzaName = "Peporoni", Topping1 = 1, Topping2 = 2, Size = 1, Crust = 1, Price = 12.0m }; context.Apizzas.Add(top); context.SaveChanges(); } }