public Pizza CreatePizza(string name, List <Topping> toppings) { var pizza = new Pizza(name, toppings); Pizzas.Add(pizza); return(pizza); }
public ActionResult Create(Pizza pizza, int pate, List <int> ingredients) { try { if (pizza != null) { Pate patePizza = Pates.FirstOrDefault(p => p.Id == pate); List <Ingredient> ingredientsPizza = new List <Ingredient>(); foreach (var ingr in ingredients) { ingredientsPizza.Add(Ingredients.FirstOrDefault(i => i.Id == ingr)); } pizza.Id = Pizzas.Count(); pizza.Pate = patePizza; pizza.Ingredients = ingredientsPizza; Pizzas.Add(pizza); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, Pizza pizza, int pate, List <int> ingredients) { try { Pate patePizza = Pates.FirstOrDefault(p => p.Id == pate); List <Ingredient> ingredientsPizza = new List <Ingredient>(); foreach (var ingr in ingredients) { ingredientsPizza.Add(Ingredients.FirstOrDefault(i => i.Id == ingr)); } var maPizza = Pizzas.FirstOrDefault(p => p.Id == id); maPizza.Nom = pizza.Nom; maPizza.Pate = patePizza; maPizza.Ingredients = ingredientsPizza; Pizzas.Remove(Pizzas.FirstOrDefault(p => p.Id == maPizza.Id)); Pizzas.Add(maPizza); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task Add(Pizza pizza) { await Pizzas.Add(pizza); var response = await Pizzas.Get(pizza.Id); Assert.Equal(pizza, response); }
public void MakeGreekPizza() { //requirement: An order can only have 50 pizza's if (ValidateUnderPizzaLimit()) { Pizzas.Add(_pizzaFactory.Make <GreekPizza>()); } ValidateUnderPriceLimit(); }
public async Task GetToppingsForPizza(Pizza p) { await Pizzas.Add(p); var results = (await Toppings.GetToppingsForPizza(p)).ToList(); Assert.Equal(p.Toppings.Count, results.Count); Assert.All(results, t => Assert.Contains(t, p.Toppings)); }
public void AddPizza() { if (currentPizza is null) { return; } currentPizza.Price = PricePizza(currentPizza).Result; Pizzas.Add(currentPizza); currentPizza = null; }
public async Task Add_NoToppings(Pizza p) { p.Toppings.Clear(); await Pizzas.Add(p); var response = await Pizzas.Get(p.Id); Assert.Equal(p, response); Assert.Empty(await Toppings.GetAll()); }
public IActionResult Add3() { Pizza pizza = new Pizza(); pizza.CrustId = 1; pizza.PizzaSizeId = 3; pizza.PizzaPrice = (decimal)13.74; Pizzas.Add(pizza); Bill += pizza.PizzaPrice; return(View("AddOrder")); }
public async Task GetManyByEnumerable(List <Pizza> ps, Pizza exclude) { await Pizzas.Add(exclude); await Pizzas.AddMany(ps); var results = (await Pizzas.GetMany(ps.Select(p => p.Id))).ToList(); Assert.Equal(ps.Count, results.Count); Assert.All(ps, p => Assert.Contains(p, results)); Assert.DoesNotContain(exclude, results); }
public async Task DeleteById(Pizza p) { await Pizzas.Add(p); await Pizzas.Delete(p.Id); Assert.Empty(await Pizzas.GetAll()); var toppings = (await Toppings.GetAll()).ToList(); Assert.Equal(p.Toppings.Count, toppings.Count); Assert.All(toppings, t => Assert.Contains(t, p.Toppings)); }
public void AddToBasket(Pizza pizza) { if (Pizzas == null) { List <Pizza> p = new List <Pizza>(); p.Add(pizza); Pizzas = p; } else { Pizzas.Add(pizza); } SetBasketCost(); }
public async Task Edit_NoToppings(Pizza p, Pizza changes) { await Pizzas.Add(p); p.BasePrice = changes.BasePrice; p.Description = changes.Description; p.Name = changes.Name; p.Toppings.Clear(); await Pizzas.Edit(p); var result = await Pizzas.Get(p.Id); Assert.Equal(p, result); }
public void CreatePizza(string name, string size, string crust, List <string> toppings) { if (PriceOrder < 250 || Pizzas.Count < 50) //Less than $250 or 50 pizza requirement { Pizzas.Add(new Pizza(name, size, crust, toppings)); if (PriceOrder > 250) { System.Console.WriteLine("Your pricing exceeds $250 dollar. Please remove one of the pizza."); //Place holder for method to resolve this. } } else { System.Console.WriteLine("You can not add anymore Pizza because you have 50 pizza in cart or the total price is over $250"); } }
public async Task AddPizzaAsync() { var pizza = new Pizza(); pizza.Name = AddName; pizza.Price = AddPrice; pizza.Content = AddContent; pizza.Diametr = AddDiametr; pizza.Restaurant = username; var response = await client.PostAsJsonAsync($"api/pizzas", pizza); if (response.IsSuccessStatusCode) { Pizzas.Add(pizza); } }
public Pizza CreatePizza() { if (Pizzas.Count >= 50) { throw new Exception("Cart overload! Tried to create a new pizza but there is already a maximum amount of 50."); } else if (getPrice() > 246) { throw new Exception("Cart overload! Tried to create a new pizza but it would exceed the price of 250."); } else { Pizza za = new Pizza(); Pizzas.Add(za); return(za); } }
public async Task DeleteManyByEnumerableId(List <Pizza> pizzas, Pizza exclude) { await Pizzas.Add(exclude); await Pizzas.AddMany(pizzas); await Pizzas.DeleteMany(pizzas.Select(p => p.Id)); var ps = (await Pizzas.GetAll()).ToList(); var ts = (await Toppings.GetAll()).ToList(); var expectedToppings = pizzas.SelectMany(p => p.Toppings).Concat(exclude.Toppings).ToList(); Assert.Equal(1, ps.Count); Assert.Contains(exclude, ps); Assert.Equal(expectedToppings.Count, ts.Count); Assert.All(ts, t => Assert.Contains(t, expectedToppings)); }
public Pizza CreatePizza(string name, string size, string crust, List <string> toppings) { Pizza p = new Pizza(toppings) { Name = new Name() { PizzaName = name }, Size = new Size() { Name = size }, Crust = new Crust() { Name = crust } }; Pizzas.Add(p); //toppings set in constructor return(p); }
public void MakePizza(string Crust, string Size, string Topping1, string Topping2, string Topping3, string Topping4, string Topping5) { Pizza p = new Pizza(Crust, Size, Topping1, Topping2, Topping3, Topping4, Topping5); Price += 9.99; if (p.Crust == "CHEESE") { Price += 5; } if (p.Size == "SMALL") { Price -= 5; } if (p.Size == "LARGE") { Price += 5; } if (Topping1 != "") { Price += 5; } if (Topping2 != "") { Price += 5; } if (Topping3 != "") { Price += 5; } if (Topping4 != "") { Price += 5; } if (Topping5 != "") { Price += 5; } Pizzas.Add(p); }
/// <summary> /// Add Pizzas to Order /// If quantity of pizzas > 12 or amount > 500 doesn't add the pizza /// </summary> /// <param name="pizza"></param> public bool AddPizza(Pizza pizza) { double newValue = Value + pizza.Price; if (Pizzas.Count >= 12) { Console.WriteLine("Maximum quantity of pizzas allowed (12 pizzas)"); return(false); } else if (newValue > 500) { Console.WriteLine("Maximum Order Amount Allowed ($ 500)"); return(false); } else { Pizzas.Add(pizza); Value += pizza.Price; Console.Write(" - added"); Console.WriteLine(); return(true); } }
public bool CreatePizza(Pizza factory) { var pizza = factory; if (OrderAmount + pizza.PizzaPrice > 250) { System.Console.WriteLine("Order exceeded maximum amount allowed per order"); System.Console.WriteLine($"Current order total: ${OrderAmount}"); System.Console.WriteLine($"Current pizza price ${pizza.PizzaPrice}"); System.Console.WriteLine($"Order exceeds by: ${(OrderAmount + pizza.PizzaPrice) - 250}"); System.Console.WriteLine("Please try again"); System.Console.WriteLine(); return(false); } else if (!IsPizzasInRange()) { System.Console.WriteLine("Order exceeded maximum amount of Pizzas allowed per order"); System.Console.WriteLine(); return(false); } Pizzas.Add(pizza); // System.Console.WriteLine("Pizza added succesfully to cart"); return(true); }
public void CreatePizza(string size, string crust, List <string> toppings) { if (NumberOfPizzasOrdered < 50) { Pizza p = new Pizza(size, crust, toppings); if (TotalCostOfOrder + p.ComputePricing() < 250) { Pizzas.Add(p); NumberOfPizzasOrdered = NumberOfPizzasOrdered + 1; TotalCostOfOrder = TotalCostOfOrder + p.ComputePricing(); } else { System.Console.WriteLine(); System.Console.WriteLine("Sorry but orders can't go over $250"); System.Console.WriteLine("Trust us, its for your own good."); } } else { System.Console.WriteLine(); System.Console.WriteLine("Sorry we can't make more then 50 pizzas at a time."); } }
public Order AddPizza(Pizza pizza) { ValidateNewPizza(pizza); Pizzas.Add(pizza); return(this); }
public void CreatePizza() { Pizzas.Add(new Pizza()); }
public void AdicionarPizza(Pizza pizza) { Pizzas.Add(pizza); }
public void MakeGlutenFreePizza() { Pizzas.Add(_pizzaFactory.Make <GlutenFreePizza>()); }
public void MakeBuffaloChickenPizza() { Pizzas.Add(_pizzaFactory.Make <BuffaloChickenPizza>()); }
public void MakeMeatPizza() { Pizzas.Add(_pizzaFactory.Make <MeatPizza>()); }
public void MakeCustomPizza() { Pizzas.Add(_pizzaFactory.Make <CustomPizza>()); }
public void MakePillyCheeseSteakPizza() { Pizzas.Add(_pizzaFactory.Make <PillyCheeseSteakPizza>()); }