Exemplo n.º 1
0
        private void GetPizzaQuantities()
        {
            var ef = new EfData();

            pizzaQuantities = new List <int>();

            List <int> pizzaIDs        = ef.GetAllPizzaIDsForOrder(OrderID);
            int        count           = 0;
            string     lastPizzaString = ef.GetPizzaStringByPizzaID(pizzaIDs.ElementAt(0));

            for (int i = 0; i < pizzaIDs.Count; i++)
            {
                string newPizzaString = ef.GetPizzaStringByPizzaID(pizzaIDs.ElementAt(i));
                if (!newPizzaString.Equals(lastPizzaString))
                {
                    pizzaQuantities.Add(count);
                    lastPizzaString = newPizzaString;
                    count           = 1;
                }
                else
                {
                    count += 1;
                }

                if (i == pizzaIDs.Count - 1)
                {
                    pizzaQuantities.Add(count);
                }
            }
        }
Exemplo n.º 2
0
        private void GetPizzasOrderedInfo()
        {
            pizzasOrderedInfo = new List <PizzaOrderInfo>();
            var ef = new EfData();

            int count = 0;

            foreach (var pizza in GetPizzasInOrder())
            {
                var poi = new PizzaOrderInfo();
                poi.CrustID       = pizza.CrustId;
                poi.SauceID       = pizza.SauceId;
                poi.cheeseIDs     = ef.GetListCheesesByPizzaID(pizza.PizzaId).Select(p => p.CheeseId).ToList();
                poi.toppingIDs    = ef.GetListCheesesByPizzaID(pizza.PizzaId).Select(p => p.CheeseId).ToList();
                poi.PizzaQuantity = pizzaQuantities.ElementAt(count);
                count            += 1;
            }
        }
Exemplo n.º 3
0
        private bool MakeNewOrder()
        {
            var ef = new EfData();

            if (ef.ValidateCustomer(Oh.CustomerID) && ef.ValidateLocation(Oh.LocationID))
            {
                order              = new Order();
                order.LocationId   = Oh.LocationID;
                order.TotalValue   = Oh.TotalOrderValue;
                order.OrderTime    = System.DateTime.Now;
                order.CustomerId   = Oh.CustomerID;
                order.ModifiedDate = System.DateTime.Now;
                dbContext.Order.Add(order);
                dbContext.SaveChanges();
                Console.WriteLine("Added Order: {0}", order.OrderId);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        private List <Pizza> GetPizzasInOrder()
        {
            var ef = new EfData();

            return(ef.GetPizzasForOrder(OrderID));
        }