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 void Submit() { var discard = Pizzas.Where(p => !p.Done).ToList(); discard.ForEach(p => Pizzas.Remove(p)); this.Submitted = true; this.Points = this.GetTotal() * 0.25m; }
public void DeletePizzaAsync() { var request = new HttpRequestMessage(HttpMethod.Delete, $"api/pizzas"); request.Content = new StringContent(JsonConvert.SerializeObject(PizzasDeleteItem), Encoding.UTF8, "application/json"); var response = this.client.SendAsync(request).Result; Pizzas.Remove(this.PizzasDeleteItem); }
public bool ValidateUnderPriceLimit() { // add this after the user has choosen their pizza if (CalculatePrice() > 250.00m) { Console.WriteLine("Your order can not be more than $250"); Pizzas.Remove(Pizzas.Last()); return(false); } return(true); }
public ActionResult Delete(int id, FormCollection collection) { try { Pizzas.Remove(Pizzas.FirstOrDefault(p => p.Id == id)); return(RedirectToAction("Index")); } catch { return(View()); } }
public void RemoveVeggiePizza() { int x = 0; while (x == 0) { foreach (APizzaModel pizza in Pizzas) { if (pizza.Name == "VeggiePizza") { Pizzas.Remove(pizza); x = 1; break; } } } OrderPrice -= 20.00M; }
public void RemovePizza(Pizzas pizzaToRemove) { Pizzas.Remove(pizzaToRemove); }