예제 #1
0
        public Pizza CreatePizza(string name, List <Topping> toppings)
        {
            var pizza = new Pizza(name, toppings);

            Pizzas.Add(pizza);
            return(pizza);
        }
예제 #2
0
        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());
            }
        }
예제 #3
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());
            }
        }
        public async Task Add(Pizza pizza)
        {
            await Pizzas.Add(pizza);

            var response = await Pizzas.Get(pizza.Id);

            Assert.Equal(pizza, response);
        }
예제 #5
0
 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));
        }
예제 #7
0
 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());
        }
예제 #9
0
        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));
        }
예제 #12
0
 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");
     }
 }
예제 #15
0
        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);
            }
        }
예제 #16
0
 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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        /// <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);
        }
예제 #22
0
 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.");
     }
 }
예제 #23
0
 public Order AddPizza(Pizza pizza)
 {
     ValidateNewPizza(pizza);
     Pizzas.Add(pizza);
     return(this);
 }
예제 #24
0
 public void CreatePizza()
 {
     Pizzas.Add(new Pizza());
 }
예제 #25
0
파일: Ordem.cs 프로젝트: tabaldi98/Pizza-IA
 public void AdicionarPizza(Pizza pizza)
 {
     Pizzas.Add(pizza);
 }
예제 #26
0
 public void MakeGlutenFreePizza()
 {
     Pizzas.Add(_pizzaFactory.Make <GlutenFreePizza>());
 }
예제 #27
0
 public void MakeBuffaloChickenPizza()
 {
     Pizzas.Add(_pizzaFactory.Make <BuffaloChickenPizza>());
 }
예제 #28
0
 public void MakeMeatPizza()
 {
     Pizzas.Add(_pizzaFactory.Make <MeatPizza>());
 }
예제 #29
0
 public void MakeCustomPizza()
 {
     Pizzas.Add(_pizzaFactory.Make <CustomPizza>());
 }
예제 #30
0
 public void MakePillyCheeseSteakPizza()
 {
     Pizzas.Add(_pizzaFactory.Make <PillyCheeseSteakPizza>());
 }