//Allows you to select a new size for the pizza static Asize SelectSize() { var context = new PizzaBoxContext(); Console.WriteLine("What Size would you like"); List <Asize> sizes = context.Asizes.ToList(); foreach (var s in sizes) { Console.WriteLine($"{s.Id} {s.SizeName} ${s.SizePrice}"); } int input = -1; do { int.TryParse(Console.ReadLine(), out input); }while(!context.Asizes.Any(p => p.Id == input)); Asize siz = context.Asizes.Where(p => p.Id == input).First(); return(siz); }
/* * 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(); } }