Esempio n. 1
0
        public void CreateOrderPizza(int?order, int?pizza)
        {
            var newOrderPizza = new OrderPizzaRepository(new PizzaPlaceContext());

            newOrderPizza.AddOrderPizza(order, pizza);
            newOrderPizza.SaveChanges();
        }
Esempio n. 2
0
        public bool PlacePreMade(decimal price, List <Pizza> currentPizza, string PizzaName, int userId, List <string> myToppings)
        {
            bool check       = true;
            var  findUser    = new UsersRepository(new PizzaPlaceContext());
            var  findOrderId = new OrderPizzaRepository(new PizzaPlaceContext());

            if (userId == 0)
            {
                userId = findUser.GetUserIDByPhone(user.Name, user.Phone);
            }
            var           minus = new InventoryRepository(new PizzaPlaceContext());
            bool          hasDough = true, hasSauce = true;
            List <string> noTopping = new List <string>();

            // check inventory

            check = minus.CheckInventory(myToppings, currentPizza, user.LocationID, hasDough, hasSauce, noTopping);
            if (check == false)
            {
                return(false);
            }



            //minus in invetory
            minus.MinusToppings(myToppings, currentPizza, user.LocationID);

            //insert pizza
            foreach (Pizza pizzas in currentPizza)
            {
                CreatePizza(pizzas.Size, pizzas.price, pizzas.Name, pizzas.Crust);
            }

            double priceDouble = double.Parse(price.ToString());//total price

            //insert order
            CreateOrder(priceDouble, userId);


            //orderPizza
            string size = currentPizza[0].Size, nameofPizza = currentPizza[0].Size;

            int?order_id = findOrderId.GetOrderByUserId(userId);

            //int? pizza_id = findOrderId.GetPizzaIdBySize(nameofPizza, size);
            foreach (Pizza pizzas in currentPizza)
            {
                var id = pizzas.DefaultPizzaInventoryId;

                CreateOrderPizza(order_id, id);
            }



            //hasTopping
            string name;
            int?   pizza_id;

            foreach (Pizza pizzas in currentPizza)
            {
                name     = pizzas.Name;
                size     = pizzas.Size;
                pizza_id = findOrderId.GetPizzaIdBySize(name, size);
                CreateHasTopping(pizza_id, pizzas.DefaultPizzaInventoryId);
            }


            return(true);
        }