public void Test()
    {
        var a = new A();                 // Compile error

        a = new Astore().GetInstanceOfA();
        a.MemberFunctionOfA();
    }
Exemplo n.º 2
0
        static void CreateOrder(Astore orderingStore, Acustomer orderingCustomer)
        {
            var           context  = new PizzaBoxContext();
            int           input    = -1;
            List <Apizza> pizzas   = new List <Apizza>();
            var           newOrder = new Aorder()
            {
                OrderId     = (context.Aorders.Any(o => o.OrderId == 1))?context.Aorders.Max(o => o.OrderId) + 1: 1,
                CustomerId  = orderingCustomer.Id,
                StoreId     = orderingStore.Id,
                TimeOrdered = DateTime.Now
            };

            Console.WriteLine("What Pizza Do you want in your order");
            do
            {
                if (input != 2)
                {
                    pizzas.Add(SelectPizza());
                    ModifyPizza(pizzas[pizzas.Count - 1]);
                }
                else
                {
                    RemovePizza(pizzas);
                }
                Console.WriteLine("Order Total $: " + newOrder.TotalPrice(pizzas).Value);

                if (pizzas.Count >= maxPizzaCount || newOrder.TotalPrice(pizzas) > maxPizzaOrder)
                {
                    input = 0;
                    Console.WriteLine("You have reached the limit of your order");
                }
                else
                {
                    Console.WriteLine("Do you want another pizza. 0 for no 1 for yes 2 to remove pizza");
                    int.TryParse(Console.ReadLine(), out input);
                }
            }while(!(input == 0));

            foreach (var p in pizzas)
            {
                Console.WriteLine(p.ToString());
            }
            var totalPrice = 0m;

            foreach (var p in pizzas)
            {
                totalPrice += p.GetPizzaPrice();
            }


            SubmitOrder(newOrder, pizzas);
        }
Exemplo n.º 3
0
        //Checks to see if the customer has used this store within a time frame
        static bool checkCustomerStore(Acustomer checkCust, Astore checkStore, int storeLimit)
        {
            var context   = new PizzaBoxContext();
            var query     = context.Aorders.Where(c => c.CustomerId == checkCust.Id);
            var queriable = query.Where(d => d.StoreId == checkStore.Id);

            if (queriable.Any(t => t.TimeOrdered >= DateTime.Now.AddHours(-storeLimit)))
            {
                Console.WriteLine("You have ordered in the last " + storeLimit + " hours");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        //Overloaded function
        //This will view the orders of a store based on the input from the user
        static void ViewOrders(Astore stor)
        {
            Console.WriteLine("How many days back do you want to veiw orders :");
            int.TryParse(Console.ReadLine(), out int input);
            var context   = new PizzaBoxContext();
            var queriable = context.Aorders.Where(o => o.StoreId == stor.Id).ToList();
            var ord       = queriable.Where(o => o.TimeOrdered >= DateTime.Now.AddDays(-input));

            foreach (var o in ord)
            {
                Console.WriteLine("Order # " + o.OrderId + " " + o.TimeOrdered + " $" + o.Total);
                List <AorderedPizza> piz = context.AorderedPizzas.Where(pi => pi.OrderId == o.OrderId).ToList();
                foreach (var p in piz)
                {
                    Console.WriteLine("    " + p.ToString());
                }
            }
        }
Exemplo n.º 5
0
        //Displays stores and allows you to pick one
        static Astore SelectStores()
        {
            var           context = new PizzaBoxContext();
            List <Astore> stores  = context.Astores.ToList();

            foreach (var s in stores)
            {
                Console.WriteLine(s);
            }
            int input = -1;

            do
            {
                int.TryParse(Console.ReadLine(), out input);
            }while(!context.Astores.Any(p => p.Id == input));
            Astore store = context.Astores.Where(p => p.Id == input).First();

            Console.WriteLine(store.StoreName + " Selected");
            return(store);
        }
Exemplo n.º 6
0
        /*
         *  This will check the database for any item that isn't part of anything that generates
         *  and will give it default values
         */
        static void checkDatabase()
        {
            var context = new PizzaBoxContext();

            if (!context.Astores.Any())
            {
                var top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Freddys Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
                top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Chicago Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
            }
            if (!context.Atoppings.Any())
            {
                var top = new Atopping()
                {
                    ToppingName  = "Cheese",
                    ToppingPrice = 0m,
                    Id           = 1
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
                top = new Atopping()
                {
                    ToppingName  = "Peporoni",
                    ToppingPrice = 0.5m,
                    Id           = 2
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
            }
            if (!context.Acrusts.Any())
            {
                var top = new Acrust()
                {
                    CrustName  = "Thin",
                    CrustPrice = 0m,
                    Id         = 1
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Regular",
                    CrustPrice = 0m,
                    Id         = 2
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Deep Dish",
                    CrustPrice = 1m,
                    Id         = 3
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Stuff Crust",
                    CrustPrice = 2m,
                    Id         = 4
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
            }
            if (!context.Asizes.Any())
            {
                var top = new Asize()
                {
                    SizeName  = "Small",
                    SizePrice = 0m,
                    Id        = 1
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Medium",
                    SizePrice = 1m,
                    Id        = 2
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Large",
                    SizePrice = 2m,
                    Id        = 3
                };
                context.Asizes.Add(top);
                context.SaveChanges();
            }
            if (!context.Apizzas.Any())
            {
                var top = new Apizza()
                {
                    Id        = 1,
                    PizzaName = "Cheese Pizza",
                    Topping1  = 1,
                    Topping2  = 1,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 10.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
                top = new Apizza()
                {
                    Id        = 2,
                    PizzaName = "Peporoni",
                    Topping1  = 1,
                    Topping2  = 2,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 12.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
            }
        }