public IActionResult Delete(string pizzaid, string orderid, string id) { decimal NewPrice = new decimal(); Order _order = Repo.OrderRepo.GetOrderById(long.Parse(orderid)); APizzaModel _pizza = Repo.OrderRepo.GetPizza(long.Parse(orderid), long.Parse(pizzaid)); NewPrice = _order.Price; NewPrice -= _pizza.Crust.price; NewPrice -= _pizza.Size.price; // foreach(var topping in _pizza.Toppings) // { // NewPrice -= topping.price; // } Repo.OrderRepo.DeletePizzaByID(_pizza); _order.Price = NewPrice; ViewBag.OrderPrice = NewPrice; Repo.Save(); var Order = new OrderViewModel(); var zaList = Repo.OrderRepo.GetOrdersByID(long.Parse(orderid)).Pizzas; var tempOrder = new List <APizzaModel>(); foreach (var za in zaList) { tempOrder.Add(Repo.OrderRepo.GetPizza(long.Parse(orderid), za.EntityId)); } Order.Pizzas = tempOrder; ViewBag.Username = id; ViewBag.OrderId = orderid; return(View("OrderList", Order)); }
protected void AddSauce(APizzaModel p) { Sauce = p.Sauce; if (CustomizeOrNot("sauce", Sauce)) { CustomizeSauce(); } }
protected void AddCrust(APizzaModel p) { Crust = p.Crust; if (CustomizeOrNot("crust", Crust)) { CustomizeCrust(); } }
protected void AddSize(APizzaModel p) { Size = p.Size; if (CustomizeOrNot("size", Size)) { CustomizeSize(); } }
public CustomPizza(APizzaModel p) { AddName(p); AddSize(p); AddCrust(p); AddSauce(p); AddToppings(p); CalculatePrice(); }
static decimal GetPriceOfPizza(APizzaModel Pizza) { decimal priceOfPie = 0; priceOfPie += Pizza.Crust.price; priceOfPie += Pizza.Size.price; foreach (Topping toppings in Pizza.Toppings) { priceOfPie += toppings.price; } return(priceOfPie); }
public decimal GetPriceOfPizza(long pizzaid) { APizzaModel pizza = FindByID(pizzaid); decimal piePrice = 0; piePrice += pizza.Crust.price; piePrice += pizza.Size.price; foreach (var topping in pizza.Toppings) { piePrice += topping.price; } return(piePrice); }
public void Save(APizzaModel pizza) { _ctx.Pizzas.Add(pizza); _ctx.Database.OpenConnection(); try { _ctx.SaveChanges(); } finally { _ctx.Database.CloseConnection(); } }
protected void AddName(APizzaModel p) { if (p.Name == "Cheese") { Name = "Custom"; } else if (p.Name.Contains("Custom")) { Name = p.Name; //This accounts for modifying a custom pizza a second time } else { Name = "Custom " + p.Name; } }
public static decimal GetSpecifiedPizzaTypePrice(string pizzaType) { APizzaModel pizza = null; switch (pizzaType) { case "Meat": pizza = new MeatPizza(); return(pizza.TypePrice); case "Pineapple": pizza = new PineapplePizza(); return(pizza.TypePrice); case "Gumbo": pizza = new GumboPizza(); return(pizza.TypePrice); default: return(0.0m); } }
protected void AddToppings(APizzaModel p) { Toppings = p.Toppings; //Need a prompt specific to toppings, to account for plurals Console.WriteLine($"\nYou currently have the following toppings: \n{ToppingsString()} \nWould you like to customize this? (Y/N)"); if (YesNo()) { string pt = ToppingsString(); Toppings = new List <Topping>(); bool done = false; while (!done) { Console.WriteLine($"\nPrevious Toppings: {pt} \nCurrent Toppings: {ToppingsString()} \nAdd another topping? (Y/N)"); if (YesNo()) { done = AddATopping(); } else { done = true; } } } }
public void SavePizzaModel(APizzaModel pizzaModel) { _db.Add(pizzaModel); _db.SaveChanges(); }
public void AddPizza(int choice) { if (choice == 1) { // check to see if amount of pizza is less than 50 if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <PepperoniPizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 2) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <FourCheesePizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 3) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <VeggiePizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 4) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <MeatPizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 5) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <MeatPizza>(); p.OrderId = EntityId; p.Size = "Large"; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 6) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <PepperoniPizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 7) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <FourCheesePizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 8) { if (Pizzas.Count < 25) { APizzaModel p = _pizzaFactory.Make <VeggiePizza>(); p.OrderId = EntityId; Pizzas.Add(p); Total = Total + 10; } else { Console.WriteLine("Max Order amount reached"); } } else if (choice == 0) { System.Console.WriteLine("Finished Ordering.."); } else { System.Console.WriteLine("Choose a valid option"); } }
public void DeletePizzaByID(APizzaModel pizza) { _context.Remove(pizza); _context.SaveChanges(); }
public PizzaTopping(APizzaModel pizza, Topping topping) { Pizza = pizza; Topping = topping; }
private void AddMajorPizzaParts(APizzaModel currentPizza, string crustName, string sizeName, List <Crust> availCrusts, List <Size> availSizes, List <Topping> availToppings) { currentPizza.AddCrust(availCrusts, crustName); currentPizza.AddSize(availSizes, sizeName); currentPizza.AddToppings(availToppings); }
public IActionResult MakeNewPizza(string id, string orderid, PizzaViewModel Pizza) { if (ModelState.IsValid) { User _user; Order _order; decimal Price = 0; _user = Repo.UserRepo.GetFullUserByName(id); if (orderid == null) { _order = new Order(); } else { _order = Repo.OrderRepo.GetOrderById(long.Parse(orderid)); Price = _order.Price; } ViewBag.OrderId = _order.EntityId; ViewBag.Username = _user.Name; APizzaModel _pizza = new APizzaModel(); _pizza.Toppings = new List <Topping>(); _pizza.Crust = Repo.CrustRepo.ReadOneCrust(Pizza.CrustName); _pizza.Size = Repo.SizeRepo.ReadOneSize(Pizza.SizeName); Price += _pizza.Crust.price; Price += _pizza.Size.price; foreach (var topping in Pizza.ToppingsNames) { var _topping = Repo.ToppingRepo.ReadOneTopping(topping); _pizza.Toppings.Add(_topping); // Price+=_topping.price; } _order.Price = Price; _order.Store = _user.ChosenStore; _order.Pizzas.Add(_pizza); _user.Orders.Add(_order); ViewBag.OrderPrice = Price; Repo.Save(); var Order = new OrderViewModel(); if (orderid == null) { Order.Pizzas = _order.Pizzas; } else { var zaList = Repo.OrderRepo.GetOrdersByID(long.Parse(orderid)).Pizzas; var tempOrder = new List <APizzaModel>(); var toppinglist = new List <Topping>(); foreach (var za in zaList) { tempOrder.Add(Repo.OrderRepo.GetPizza(long.Parse(orderid), za.EntityId)); } Order.Pizzas = tempOrder; } return(View("OrderList", Order)); } else { Pizza.DisplayCrusts = Repo.CrustRepo.ReadCrust(); Pizza.DisplaySizes = Repo.SizeRepo.ReadSize(); Pizza.DisplayToppings = Repo.ToppingRepo.ReadToppings(); return(View("AddPizza", Pizza)); } }
static List <APizzaModel> MakePizza() { bool done = false; bool done2 = false; var input = 0; List <APizzaModel> Pizzas = new List <APizzaModel>(); while (!done) { var sb = new System.Text.StringBuilder(); int counter = 1; Order temp_o = new Order(Pizzas); Console.WriteLine("Shopping Cart: "); sb.Append(String.Format("{0,-25} {1,-25} {2,-25}\n", "Pizza Number", "Pizza Name", "Total Price")); sb.Append(String.Format("{0,-25} {1,-25} {2,-25}\n", "", "", temp_o.price)); foreach (var p in Pizzas) { sb.Append(String.Format("{0,-25} {1,-25} {2,-25}\n", counter, p.name, p.price)); counter++; } Console.WriteLine(sb); Console.WriteLine("Choose one of the following options:"); Console.WriteLine("1) Preset Pizza"); Console.WriteLine("2) Custom Pizza"); Console.WriteLine("3) Finish and checkout"); int.TryParse(Console.ReadLine(), out input); if (input == 1) { if (temp_o.price <= 250 || temp_o.Pizzas.Count <= 50) { APizzaModel p = SelectPizza(); Pizzas.Add(p); Console.WriteLine("You have selected:"); Console.WriteLine("Pizza name: " + p.name, "Price: $" + p.price); } else { Console.WriteLine("Too many pizzas in cart! Limist to $250 per order or 50 items"); } } else if (input == 2) { if (temp_o.price <= 250 || temp_o.Pizzas.Count <= 50) { PrintAllCrusts(); Crust c = SelectCrust(); PrintAllSizes(); Size s = SelectSize(); List <Topping> ts = new List <Topping>(); while (!done2) { input = 0; var t = new Topping(); Console.WriteLine("Please select one of the options: "); Console.WriteLine("1) Add more toppings, " + ts.Count + "/5 Toppings"); Console.WriteLine("2) Stop"); int.TryParse(Console.ReadLine(), out input); if (input == 1) { if (ts.Count < 5) { PrintAllToppings(); ts.Add(SelectTopping()); } else { Console.WriteLine("Too many toppings!"); } } else if (input == 2) { done2 = true; Console.WriteLine("Finished adding toppings..."); } else { Console.WriteLine("Please select a valid option"); } } Console.WriteLine("Adding custom built Pizza..."); Pizzas.Add(new Pizza(c, s, ts) { name = "CustomPizza" }); } else { Console.WriteLine("Too many pizzas in cart! Limist to $250 per order or 50 items"); } } else if (input == 3) { Console.WriteLine("Checking out..."); return(Pizzas); } else { Console.WriteLine("Please enter a valid option. (number 1, 2, or 3)"); } } Console.WriteLine("WARNING: Error in MakePizza method"); return(Pizzas); }