Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                Pizzas.Remove(Pizzas.FirstOrDefault(p => p.Id == id));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 public void RemovePizza(Pizzas pizzaToRemove)
 {
     Pizzas.Remove(pizzaToRemove);
 }