Example #1
0
        public static List <dom.Pizza> GetPizzasByOrderID(int orderID)
        {
            var _db          = new dat.PizzaStoreDbContext();
            var datapizzas   = _db.Pizza.Where(p => p.OrderId == orderID).ToList();
            var domPizzaList = new List <dom.Pizza>();

            foreach (var item in datapizzas)
            {
                if ((bool)item.Active)
                {
                    var dompizza = new dom.Pizza()
                    {
                        CrustId = (int)item.CrustId
                        ,
                        crustSize = (int)item.Size
                        ,
                        OrderId = (int)item.OrderId
                        ,
                        ModifiedDate = item.ModifiedDate
                        ,
                        Id = (int)item.PizzaId
                    };

                    dompizza.Toppings    = PizzaHelper.GetIngredientsByPizza(item);
                    dompizza.CrustFactor = PizzaHelper.GetFactorByCrustID(item.CrustId);
                    dompizza.price       = dompizza.CalculateCost();

                    domPizzaList.Add(dompizza);
                }
            }
            return(domPizzaList);
        }
Example #2
0
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = new Crust();
            newPizza.Size  = new Size();

            newPizza.Crust.CrustName = pizza.Crust;
            newPizza.Size.SizeName   = pizza.Size;
            newPizza.PizzaName       = pizza.Name;
            newPizza.Qty             = pizza.Qty;
            newPizza.PizzaPrice      = pizza.Price;

            newPizza.PizzaTopping = new HashSet <PizzaTopping>();
            foreach (var t in pizza.Toppings)
            {
                var newTopping = new Topping();
                newTopping.ToppingName = t;
                newPizza.PizzaTopping.Add(new PizzaTopping {
                    Topping = newTopping, Pizza = newPizza
                });
            }
            ;

            _db.Pizza.Add(newPizza);
            _db.SaveChanges();
        }
Example #3
0
        public static List <dom.Pizza> GetPizzasByOrder(Order dr)
        {
            var _db        = new PizzaStoreDbContext();
            var pizzalist  = new List <dom.Pizza>();
            var dataPizzas = _db.Pizza.Where(p => p.OrderId == dr.OrderId).ToList();

            foreach (var item in dataPizzas)
            {
                if (item.Active == true)
                {
                    var crust = _db.Crust.Where(c => c.CrustId == item.CrustId).FirstOrDefault();
                    if (crust == null)
                    {
                        crust        = _db.Crust.Where(c => c.Name == "Regular").FirstOrDefault();
                        item.CrustId = crust.CrustId;
                    }

                    var dompizza = new dom.Pizza()
                    {
                        Id           = (int)item.PizzaId,
                        crustSize    = (int)item.Size,
                        ModifiedDate = item.ModifiedDate,
                        OrderId      = (int)item.OrderId,
                        Toppings     = PizzaHelper.GetIngredientsByPizza(item),
                        price        = PizzaHelper.GetPriceByPizza(item),
                        CrustId      = (byte)item.CrustId,
                        CrustFactor  = (double)crust.CrustFactor
                    };

                    pizzalist.Add(dompizza);
                }
            }
            return(pizzalist);
        }
Example #4
0
        public List <domain.Pizza> ReadAll()
        {
            var pizzaWithSize    = _db.Pizza.Include(t => t.Name).Include(t => t.Size).ThenInclude(t => t.Name);
            var pizzaWithCrust   = _db.Pizza.Include(t => t.Name).Include(t => t.Crust).ThenInclude(t => t.Name);
            var pizzaWithTopping = _db.PizzaTopping.Include(t => t.Topping).ThenInclude(t => t.Name).Include(t => t.Pizza).ThenInclude(t => t.Name);
            var domainPizzaList  = new List <domain.Pizza>();

            //_db.Pizza.Where(f => f.PizzaId == 1);
            foreach (var item in pizzaWithCrust.ToList())
            {
                domain.Pizza za = new domain.Pizza
                {
                    Crust = new domain.Crust {
                        Name = item.Crust.Name
                    },
                    Size = new domain.Size {
                        Name = item.Size.Name
                    },
                    Name = new domain.Name {
                        PizzaName = item.Name
                    },
                };
                //List<domain.Topping> top = new List<domain.Topping>()
                foreach (var item2 in pizzaWithTopping.ToList())
                {
                    za.Toppings.Add(new domain.Topping {
                        Name = item2.Topping.Name
                    });
                }
            }
            return(domainPizzaList);
        }
Example #5
0
        public static string GetCrustNameByPizza(dom.Pizza p)
        {
            var _db   = new PizzaStoreDbContext();
            var crust = _db.Crust.Where(c => c.CrustId == p.CrustId).FirstOrDefault();

            if (crust == null)
            {
                crust         = _db.Crust.Where(c => c.Name == "Regular").FirstOrDefault();
                p.CrustId     = crust.CrustId;
                p.CrustFactor = (double)crust.CrustFactor;
            }

            return(crust.Name);
        }
Example #6
0
        public static void DisplayPizza(dom.Pizza p)
        {
            Console.WriteLine("\n\n\n\n\n");

            var crustname = PizzaHelper.GetCrustNameByPizza(p);

            Console.WriteLine($"Pizza#{p.Id}  Size={p.crustSize}in {crustname} crust");
            Console.Write("Toppings:");
            foreach (var ingred in p.Toppings)
            {
                Console.Write($"{ingred} ");
            }
            Console.Write($"; ${p.price}\n");
        }
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = new Crust();
            newPizza.Size  = new Size();

            newPizza.Crust.CrustName = pizza.Crust;
            newPizza.Size.SizeName   = pizza.Size;
            newPizza.PizzaName       = pizza.Name;
            newPizza.PizzaPrice      = pizza.Price;

            _db.Pizza.Add(newPizza);
            _db.SaveChanges();
        }
Example #8
0
 public static void SetPizzaIngredientByIds(dom.Pizza p, int lastID)
 {
     foreach (var top in p.Toppings)
     {
         var _db     = new PizzaStoreDbContext();
         var topping = _db.Ingredient.Where(i => (i.Name).ToLower() == top.ToLower()).FirstOrDefault();
         if (topping != null)
         {
             var pipair = new PizzaIngredient()
             {
                 PizzaId = lastID, IngredientId = topping.IngredientId
             };
             _db.PizzaIngredient.Add(pipair);
             _db.SaveChanges();
         }
     }
 }
Example #9
0
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust.Name = pizza.Crust;
            newPizza.Size.Name  = pizza.Size;
            newPizza.Name       = pizza.Name;

            var orderDate = DateTime.UtcNow;

            //newPizza.DateModified = DateTime.Now;
            //newPizza.Active = false;
            //newPizza.UserModified = Identity.Hash;

            _db.Pizza.Add(newPizza);
            _db.SaveChanges();
        }
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = new Crust()
            {
                Name = pizza.crust._crust
            };
            newPizza.Size = new Size()
            {
                Name = pizza.size._size
            };
            newPizza.Name = pizza.Name;


            db.Pizza.Add(newPizza);
            db.SaveChanges();
        }
Example #11
0
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            //var newTopping = new Topping();

            _db.Crust.Add(newPizza.Crust);
            newPizza.Crust.Name = pizza.Crust.Name;
            _db.Size.Add(newPizza.Size);
            newPizza.Size.Name = pizza.Size.Name;
            newPizza.Name      = pizza.Name;
            newPizza.

            //var orderDate = DateTime.UtcNow;

            //_db.Pizza.Add(newPizza);
            //_db.Topping.Add(newTopping);
            _db.SaveChanges();
        }
Example #12
0
        private Pizza ConvertToDbPizza(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.Crust = _db.Crust.FirstOrDefault(c => c.Name == pizza.Crust.Name);
            newPizza.Size  = _db.Size.FirstOrDefault(s => s.Name == pizza.Size.Name);
            newPizza.Name  = pizza.Name;
            newPizza.Price = pizza.CalculatePrice();

            foreach (var topping in pizza.Toppings)
            {
                newPizza.PizzaTopping.Add(new PizzaTopping()
                {
                    Topping = _db.Toppings.FirstOrDefault(t => t.Name == topping.Name)
                });
            }

            return(newPizza);
        }
Example #13
0
        public static int PizzaSetter(dom.Pizza p)
        {
            var _db     = new PizzaStoreDbContext();
            var myOrder = _db.Order.Where(o => o.OrderId == p.OrderId).FirstOrDefault();
            var myCrust = _db.Crust.Where(c => c.CrustId == p.CrustId).FirstOrDefault();

            if (myCrust == null)
            {
                var DefaultCrust = _db.Crust.Where(c => c.Name == "Regular").FirstOrDefault();
                p.CrustId     = DefaultCrust.CrustId;
                p.CrustFactor = (double)DefaultCrust.CrustFactor;
            }

            if (myOrder == null)
            {
                return(0);
            }
            else
            {
                var dataPizza = new Pizza()
                {
                    OrderId      = p.OrderId,
                    ModifiedDate = DateTime.Now,
                    Price        = (decimal)p.CalculateCost(),
                    Size         = (byte)p.crustSize,
                    CrustId      = (byte)p.CrustId,
                };

                _db.Pizza.Add(dataPizza);

                var pizzaAdditions = _db.SaveChanges();

                var fullPizzaList = GetPizzas();
                var lastPizza     = fullPizzaList[fullPizzaList.Count - 1];
                var lastPizzaID   = lastPizza.Id;
                SetPizzaIngredientByIds(p, lastPizzaID);

                return(pizzaAdditions);
            }
        }
Example #14
0
        public void Create(domain.Pizza pizza)
        {
            var newPizza = new Pizza();

            newPizza.PizzaCrust = pizza.Crust;
            newPizza.Size       = pizza.Size;
            newPizza.PizzaName  = pizza.Name;
            newPizza.Price      = pizza.Price;

            _db.Pizza.Add(newPizza);
            _db.SaveChanges();

            var newPizzaTopping = new Topping();

            foreach (string t in pizza.Toppings)
            {
                newPizzaTopping.PizzaId     = newPizza.PizzaId;
                newPizzaTopping.ToppingName = t;
                _db.Topping.Add(newPizzaTopping);
                _db.SaveChanges();
            }
        }
Example #15
0
        //private static PizzaStoreDbContext _db = new PizzaStoreDbContext();

        public static List <dom.Pizza> GetPizzas()
        {
            var _db = new PizzaStoreDbContext();
            var ls  = new List <dom.Pizza>();

            foreach (var l in _db.Pizza.ToList())
            {
                if (l.Active == true)
                {
                    var crust = _db.Crust.Where(c => c.CrustId == l.CrustId).FirstOrDefault();

                    if (crust == null)
                    {
                        crust     = _db.Crust.Where(c => c.Name == "Regular").FirstOrDefault();
                        l.CrustId = crust.CrustId;
                    }

                    var newPizza = new dom.Pizza()
                    {
                        Id = (int)l.PizzaId
                        ,
                        OrderId = (int)l.OrderId
                        ,
                        ModifiedDate = l.ModifiedDate
                        ,
                        crustSize = (int)l.Size
                        ,
                        CrustFactor = (double)crust.CrustId
                        ,
                        CrustId = (byte)l.CrustId
                    };
                    ls.Add(newPizza);
                }
            }

            return(ls);
        }
Example #16
0
        public void CreatePizza(domain.Pizza pizza, domain.Order order, domain.Store store, domain.User user)
        {
            var newPizza        = new Pizza();
            var newTopping      = new Topping();
            var newPizzaTopping = new PizzaTopping();

            //var newOPT = new OrdersPizzaTopping();
            //var newOrder = new Orders();
            //var newStore = new Store();
            //var newUser = new Users();
            //newPizza.Crust = _db.Crust.FirstOrDefault(Crust ==> Name = pizza.Crust.Name);

            newPizza.Crust = new Crust()
            {
                Name = pizza.Crust.Name
            };
            newPizza.Size = new Size()
            {
                Name = pizza.Size.Name
            };
            newPizza.Name = pizza.Name.PizzaName;
            _db.Pizza.Add(newPizza);    //git add equiv for db
            _db.SaveChanges();

            //newOrder.OrderDate = order.DateOrdered;//retrieve current order

            /*var orderNum = _db.Orders.Include(d => d.OrdersPizzaTopping)
             *   .Where(f => f.OrderDate == newOrder.OrderDate)
             *   .FirstOrDefault(); //should only be one order
             *
             * newStore.Name = store.Name;//retrieve current order
             * var storeNum = _db.Store.Include(d => d.OrdersPizzaTopping)
             *   .Where(f => f.Name == newStore.Name)
             *   .FirstOrDefault(); //should only be one order
             *
             * newUser.Name = user.Name;//retrieve current order
             * var userNum = _db.Users.Include(d => d.OrdersPizzaTopping)
             *   .Where(f => f.Name == newUser.Name)
             *   .FirstOrDefault(); //should only be one order
             */

            foreach (var item in pizza.Toppings)
            {
                newTopping = new Topping {
                    Name = item.Name
                };
                _db.Topping.Add(newTopping);
                _db.SaveChanges();    //add to topping table

                //newPizzaTopping.PizzaId = newPizza.PizzaId;
                //newPizzaTopping.ToppingId = newTopping.ToppingId;
                //_db.PizzaTopping.Add(newPizzaTopping);
                //_db.SaveChanges();//add to PizzaTopping table

                //newOPT.OrderId = orderNum.OrderId;
                //newOPT.StoreId = storeNum.StoreId;
                //newOPT.UserId = userNum.UserId;
                //newOPT.PizzaToppingId = newPizzaTopping.PizzaToppingId;
                //_db.OrdersPizzaTopping.Add(newOPT); //add to OPT table
                //_db.SaveChanges(); //git commit equiv for db
            }
        }
        public static void RunApplication()
        {
            MenuManager menu                   = new MenuManager();
            bool        terminateProgram       = false;
            User        currentUser            = null;
            int         currentEditRemoveIndex = 0;
            bool        editingPizza           = false;

            Domain.Models.Pizza CurrentCustomPizza    = null;
            Domain.Models.Pizza CurrentCustomPizzaOld = null;
            do
            {
                int input = 0;
                //Entry menu
                while (menu.currentMenu == 0)
                {
                    menu.DisplayEntryText();
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("To Login...");
                            menu.currentMenu = 1;
                            break;

                        case 2:
                            System.Console.WriteLine("To Register...");
                            menu.currentMenu = 2;
                            break;

                        case 3:
                            System.Console.WriteLine("Exiting...");
                            menu.currentMenu = -1;
                            terminateProgram = true;
                            break;


                        default:
                            System.Console.WriteLine("That is not an option");
                            break;
                        }
                        System.Console.WriteLine();
                    }
                }

                //Login menu
                while (menu.currentMenu == 1)
                {
                    menu.DisplayLoginMenu();

                    //logon function
                    string userName = Console.ReadLine();
                    if (int.TryParse(userName, out input))
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("To Register");
                            menu.currentMenu = 2;
                            break;

                        case 2:
                            System.Console.WriteLine("Returning...");
                            menu.currentMenu = 0;
                            break;

                        default:
                            System.Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                    else
                    {
                        switch (userName)
                        {
                        case "User":
                            System.Console.WriteLine("Welcome User!");
                            currentUser = new User(userName, userName);    //use sql to check and see if this user has set a "real" name
                            currentUser.Orders.Add(new Order());
                            menu.currentMenu = 3;
                            break;

                        case "Shop":
                            System.Console.WriteLine("Welcome Shop!");
                            menu.currentMenu = 3;
                            break;

                        default:
                            System.Console.WriteLine("Invalid Username");
                            break;
                        }
                    }
                    System.Console.WriteLine();
                }

                //Register menu
                while (menu.currentMenu == 2)
                {
                    menu.DisplayRegisterMenu();

                    //register function
                    string userName = Console.ReadLine();
                    if (int.TryParse(userName, out input))
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("To Login");
                            menu.currentMenu = 1;
                            break;

                        case 2:
                            System.Console.WriteLine("Returning...");
                            menu.currentMenu = 0;
                            break;

                        default:
                            System.Console.WriteLine("That is not a valid option");
                            break;
                        }
                    }
                    else
                    {
                        System.Console.WriteLine("You have Been Registered!");
                        menu.currentMenu = 1;
                    }
                    System.Console.WriteLine();
                }

                //SelectLocation menu
                while (menu.currentMenu == 3)
                {
                    menu.DisplayChooseLocationMenu();

                    if (int.TryParse(Console.ReadLine(), out input))
                    {
                        switch (input)
                        {
                        case 1:
                            Console.WriteLine("Selected Dev's Pizza - Downtown");
                            if (currentUser != null)
                            {
                                currentUser.ChosenStore = new Store("Dev's Pizza - Downtown", "Store1");
                                menu.currentMenu        = 4;
                            }
                            else
                            {    //if shop, go to ShopMainMenu instead
                                menu.currentMenu = 11;
                            }
                            break;

                        case 2:
                            Console.WriteLine("Selected Dev's Pizza - Westside");
                            if (currentUser != null)
                            {
                                currentUser.ChosenStore = new Store("Dev's Pizza - Westside", "Store2");
                                menu.currentMenu        = 4;
                            }
                            else
                            {    //if shop, go to ShopMainMenu instead
                                menu.currentMenu = 11;
                            }
                            break;

                        case 3:
                            Console.WriteLine("Logged Out");
                            menu.currentMenu = 0;
                            if (currentUser != null)
                            {
                                currentUser = null;
                            }    //if shop, destroy currentShopUser
                            break;

                        default:
                            System.Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                //MainMenu
                while (menu.currentMenu == 4)
                {
                    menu.DisplayMainMenu();

                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("Proceeding to Custom Pizza...");
                            menu.currentMenu = 7;
                            break;

                        case 2:
                            System.Console.WriteLine("Added Cheese Pizza");
                            currentUser.Orders[currentUser.Orders.Count - 1].CreatePizza(
                                "Cheese",
                                new List <Domain.Models.Topping>()
                            {
                                new Domain.Models.Topping("Marinara Sauce", 0),
                                new Domain.Models.Topping("Regular Cheese", 0)
                            },
                                new Domain.Models.Crust("Plain", 0),
                                new Domain.Models.Size("Large", 4),
                                6);
                            break;

                        case 3:
                            System.Console.WriteLine("Added Pepperoni Pizza");
                            currentUser.Orders[currentUser.Orders.Count - 1].CreatePizza(
                                "Pepperoni",
                                new List <Domain.Models.Topping>()
                            {
                                new Domain.Models.Topping("Marinara Sauce", 0),
                                new Domain.Models.Topping("Regular Cheese", 0),
                                new Domain.Models.Topping("Pepperoni", 1)
                            },
                                new Domain.Models.Crust("Plain", 0),
                                new Domain.Models.Size("Large", 4),
                                6);
                            break;

                        case 4:
                            System.Console.WriteLine("Added Hawaiian Pizza");
                            currentUser.Orders[currentUser.Orders.Count - 1].CreatePizza(
                                "Hawaiian",
                                new List <Domain.Models.Topping>()
                            {
                                new Domain.Models.Topping("Marinara Sauce", 0),
                                new Domain.Models.Topping("Regular Cheese", 0),
                                new Domain.Models.Topping("Pineapples", .75),
                                new Domain.Models.Topping("Ham", 1.25)
                            },
                                new Domain.Models.Crust("Plain", 0),
                                new Domain.Models.Size("Large", 4),
                                6);
                            break;

                        case 5:
                            System.Console.WriteLine("Added Buffalo Chicken Pizza");
                            currentUser.Orders[currentUser.Orders.Count - 1].CreatePizza(
                                "Buffalo Chicken",
                                new List <Domain.Models.Topping>()
                            {
                                new Domain.Models.Topping("Marinara Sauce", 0),
                                new Domain.Models.Topping("Regular Cheese", 0),
                                new Domain.Models.Topping("Chicken", 2),
                                new Domain.Models.Topping("Buffalo Hot Sauce", .25)
                            },
                                new Domain.Models.Crust("Plain", 0),
                                new Domain.Models.Size("Large", 4),
                                6);
                            break;

                        case 6:
                            System.Console.WriteLine("Displaying Cart...");
                            System.Console.WriteLine(currentUser.Orders[currentUser.Orders.Count - 1].ToString());
                            break;

                        case 7:
                            System.Console.WriteLine("Proceeding to Edit Items...");
                            menu.currentMenu = 5;
                            break;

                        case 8:
                            System.Console.WriteLine("Proceeding to Checkout...");
                            menu.currentMenu = 8;
                            break;

                        case 9:
                            System.Console.WriteLine("Proceeding to Profile Settings...");
                            break;

                        case 10:
                            System.Console.WriteLine("Logged out");
                            currentUser      = null;
                            menu.currentMenu = 0;
                            break;

                        default:
                            System.Console.WriteLine("That is not an option");
                            break;
                        }
                        System.Console.WriteLine();
                    }
                }

                while (menu.currentMenu == 5)//Select item for Edit/Remove menu
                {
                    menu.DisplaySelectEditRemovePizzaMenu(currentUser.Orders[currentUser.Orders.Count - 1]);
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        if (input > 0 && input < currentUser.Orders[currentUser.Orders.Count - 1].Pizzas.Count + 1)
                        {
                            currentEditRemoveIndex = input - 1;
                            menu.currentMenu       = 6;
                        }
                        else if (input == currentUser.Orders[currentUser.Orders.Count - 1].Pizzas.Count + 1)
                        {
                            System.Console.WriteLine("Proceeding to Main Menu...");
                            menu.currentMenu = 4;
                        }
                        else
                        {
                            System.Console.WriteLine("That is not an option");
                        }
                    }
                }

                while (menu.currentMenu == 6) //edit/remove item menu
                {
                    menu.DisplayEditRemovePizzaMenu(currentUser.Orders[currentUser.Orders.Count - 1].Pizzas[currentEditRemoveIndex]);
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            Console.WriteLine("Proceeding to Edit Menu");
                            CurrentCustomPizza    = currentUser.Orders[currentUser.Orders.Count - 1].Pizzas[currentEditRemoveIndex];
                            CurrentCustomPizzaOld = new PizzaStore.Domain.Models.Pizza(CurrentCustomPizza);
                            editingPizza          = true;
                            menu.currentMenu      = 7;
                            //set "edit pizza" to whatever selected pizza is
                            break;

                        case 2:
                            currentUser.Orders[currentUser.Orders.Count - 1].RemovePizza(currentEditRemoveIndex);
                            menu.currentMenu       = 5;
                            currentEditRemoveIndex = 0;
                            Console.WriteLine("Item Removed");
                            Console.WriteLine("Returning to Edit/Remove menu...");
                            break;

                        case 3:
                            Console.WriteLine("Returning to Edit/Remove menu...");
                            currentEditRemoveIndex = 0;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                while (menu.currentMenu == 7)       //edit pizza menu
                {
                    if (CurrentCustomPizza == null) //creates a new "large cheese" pizza if not editing a pizza
                    {
                        CurrentCustomPizza = new Domain.Models.Pizza(
                            "Cheese",
                            new List <Domain.Models.Topping>()
                        {
                            new Domain.Models.Topping("Marinara Sauce", 0),
                            new Domain.Models.Topping("Regular Cheese", 0)
                        },
                            new Domain.Models.Crust("Plain", 0),
                            new Domain.Models.Size("Large", 4),
                            6);
                    }

                    menu.DisplayCustomizePizzaMenu(CurrentCustomPizza);

                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("proceeding to Edit Size...");
                            menu.currentMenu = 13;
                            break;

                        case 2:
                            System.Console.WriteLine("proceeding to Edit Crust...");
                            menu.currentMenu = 14;
                            break;

                        case 3:
                            System.Console.WriteLine("proceeding to Edit Sauce...");
                            menu.currentMenu = 15;
                            break;

                        case 4:
                            System.Console.WriteLine("proceeding to Edit Cheese...");
                            menu.currentMenu = 16;
                            break;

                        case 5:
                            System.Console.WriteLine("proceeding to Edit Toppings...");
                            menu.currentMenu = 17;
                            break;

                        case 6:
                            System.Console.WriteLine("Pizza Added to Order");
                            if (!editingPizza)
                            {
                                currentUser.Orders[currentUser.Orders.Count - 1].CreatePizza(CurrentCustomPizza);
                            }
                            editingPizza       = false;
                            CurrentCustomPizza = null;
                            menu.currentMenu   = 4;
                            break;

                        case 7:
                            System.Console.WriteLine("Proceeding to Main Menu...");
                            if (editingPizza)
                            {
                                currentUser.Orders[currentUser.Orders.Count - 1].Pizzas[currentEditRemoveIndex] = CurrentCustomPizzaOld;
                            }

                            editingPizza     = false;
                            menu.currentMenu = 4;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                //checkout menu
                while (menu.currentMenu == 8)
                {
                    menu.DisplayCheckoutMenu(currentUser.Orders[currentUser.Orders.Count - 1]);

                    if (int.TryParse(Console.ReadLine(), out input))
                    {
                        switch (input)
                        {
                        case 1:
                            Console.WriteLine("Placing Order...");
                            var connection = new PizzaStore.Storing.Repositories.OrderRepository();

                            connection.CreateOrderCustomerPizzaRelation(currentUser);

                            menu.currentMenu = 9;
                            break;

                        case 2:
                            Console.WriteLine("Returning to Main Menu...");
                            menu.currentMenu = 4;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                //Order Placed Menu
                while (menu.currentMenu == 9)
                {
                    menu.DisplayOrderConfirmedMenu(currentUser.Name);

                    if (int.TryParse(Console.ReadLine(), out input))
                    {
                        switch (input)
                        {
                        case 1:
                            Console.WriteLine("Starting Another order");
                            currentUser.Orders.Add(new Order());
                            menu.currentMenu = 4;
                            break;

                        case 2:
                            Console.WriteLine("Logging out...");
                            currentUser      = null;
                            menu.currentMenu = 0;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                //store main menu
                while (menu.currentMenu == 11)
                {
                    menu.DisplayStoreMainMenu();

                    if (int.TryParse(Console.ReadLine(), out input))
                    {
                        switch (input)
                        {
                        case 1:
                            Console.WriteLine("Displaying Orders");
                            System.Console.WriteLine(new PizzaStore.Storing.Repositories.OrderRepository().ReadOrderData());
                            break;

                        case 2:
                            Console.WriteLine("Proceeding to Sales...");
                            //menu.currentMenu = ;
                            break;

                        case 3:
                            Console.WriteLine("Logging Out...");
                            menu.currentMenu = 0;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }

                while (menu.currentMenu == 13)//edit pizza Size menu
                {
                    menu.DisplayEditPizzaSizeMenu();
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("Size set to Small");
                            CurrentCustomPizza.Size.SizeName = "Small";
                            CurrentCustomPizza.Size.Price    = 0;
                            menu.currentMenu = 7;
                            break;

                        case 2:
                            System.Console.WriteLine("Size set to Medium");
                            CurrentCustomPizza.Size.SizeName = "Medium";
                            CurrentCustomPizza.Size.Price    = 2;
                            menu.currentMenu = 7;
                            break;

                        case 3:
                            System.Console.WriteLine("Size set to Large");
                            CurrentCustomPizza.Size.SizeName = "Large";
                            CurrentCustomPizza.Size.Price    = 4;
                            menu.currentMenu = 7;
                            break;

                        case 4:
                            System.Console.WriteLine("Returning to Customize Menu...");
                            menu.currentMenu = 7;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }
                while (menu.currentMenu == 14)//edit pizza Crust menu
                {
                    menu.DisplayEditPizzaCrusteMenu();
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("Crust set to Plain");
                            CurrentCustomPizza.Crust.CrustName = "Plain";
                            CurrentCustomPizza.Crust.Price     = 0;
                            menu.currentMenu = 7;
                            break;

                        case 2:
                            System.Console.WriteLine("Crust set to Deep Dish");
                            CurrentCustomPizza.Crust.CrustName = "Deep Dish";
                            CurrentCustomPizza.Crust.Price     = 1;
                            menu.currentMenu = 7;
                            break;

                        case 3:
                            System.Console.WriteLine("Crust set to Stuffed");
                            CurrentCustomPizza.Crust.CrustName = "Stuffed";
                            CurrentCustomPizza.Crust.Price     = 2;
                            menu.currentMenu = 7;
                            break;

                        case 4:
                            System.Console.WriteLine("Returning to Customize Menu...");
                            menu.currentMenu = 7;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }
                while (menu.currentMenu == 15)//edit pizza Sauce menu
                {
                    menu.DisplayEditPizzaSauceeMenu();
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("Sauce set to Marinara");
                            CurrentCustomPizza.Toppings[0].TopName = "Marinara";
                            CurrentCustomPizza.Toppings[0].Price   = 0;
                            menu.currentMenu = 7;
                            break;

                        case 2:
                            System.Console.WriteLine("Sauce set to Alfredo");
                            CurrentCustomPizza.Toppings[0].TopName = "Alfredo";
                            CurrentCustomPizza.Toppings[0].Price   = .5;
                            menu.currentMenu = 7;
                            break;

                        case 3:
                            System.Console.WriteLine("Sauce set to Ranch");
                            CurrentCustomPizza.Toppings[0].TopName = "Ranch";
                            CurrentCustomPizza.Toppings[0].Price   = .5;
                            menu.currentMenu = 7;
                            break;

                        case 4:
                            System.Console.WriteLine("Returning to Customize Menu...");
                            menu.currentMenu = 7;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }
                while (menu.currentMenu == 16)//edit pizza Cheese menu
                {
                    menu.DisplayEditPizzaCheeseMenu();
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            System.Console.WriteLine("Cheese set to None");
                            CurrentCustomPizza.Toppings[1].TopName = "No Cheese";
                            CurrentCustomPizza.Toppings[1].Price   = 0;
                            menu.currentMenu = 7;
                            break;

                        case 2:
                            System.Console.WriteLine("Cheese set to Regular");
                            CurrentCustomPizza.Toppings[1].TopName = "Regular Cheese";
                            CurrentCustomPizza.Toppings[1].Price   = 0;
                            menu.currentMenu = 7;
                            break;

                        case 3:
                            System.Console.WriteLine("Cheese set to Extra");
                            CurrentCustomPizza.Toppings[1].TopName = "Extra Cheese";
                            CurrentCustomPizza.Toppings[1].Price   = .75;
                            menu.currentMenu = 7;
                            break;

                        case 4:
                            System.Console.WriteLine("Returning to Customize Menu...");
                            menu.currentMenu = 7;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }
                while (menu.currentMenu == 17)//edit pizza Toppings menu
                {
                    menu.DisplayEditPizzaToppingsMenu(CurrentCustomPizza);
                    if (int.TryParse(Console.ReadLine(), out input))//if input passes as good input, then perform selected operation
                    {
                        switch (input)
                        {
                        case 1:
                            string addRemove = (CurrentCustomPizza.CheckHasTopping("Pepperoni")) ? "Remove" : "Add";
                            System.Console.WriteLine($"Pepperoni {addRemove}ed");
                            if (addRemove == "Add")
                            {
                                CurrentCustomPizza.AddTopping(new Domain.Models.Topping()
                                {
                                    TopName = "Pepperoni", Price = 1
                                });
                            }
                            else
                            {
                                CurrentCustomPizza.RemoveTopping("Pepperoni");
                            }
                            break;

                        case 2:
                            addRemove = (CurrentCustomPizza.CheckHasTopping("Ham")) ? "Remove" : "Add";
                            System.Console.WriteLine($"Ham {addRemove}ed");
                            if (addRemove == "Add")
                            {
                                CurrentCustomPizza.AddTopping(new Domain.Models.Topping()
                                {
                                    TopName = "Ham", Price = 1.25
                                });
                            }
                            else
                            {
                                CurrentCustomPizza.RemoveTopping("Ham");
                            }
                            break;

                        case 3:
                            addRemove = (CurrentCustomPizza.CheckHasTopping("Chicken")) ? "Remove" : "Add";
                            System.Console.WriteLine($"Chicken {addRemove}ed");
                            if (addRemove == "Add")
                            {
                                CurrentCustomPizza.AddTopping(new Domain.Models.Topping()
                                {
                                    TopName = "Chicken", Price = 2
                                });
                            }
                            else
                            {
                                CurrentCustomPizza.RemoveTopping("Chicken");
                            }
                            break;

                        case 4:
                            addRemove = (CurrentCustomPizza.CheckHasTopping("Pineapple")) ? "Remove" : "Add";
                            System.Console.WriteLine($"Pineapple {addRemove}ed");
                            if (addRemove == "Add")
                            {
                                CurrentCustomPizza.AddTopping(new Domain.Models.Topping()
                                {
                                    TopName = "Pineapple", Price = .75
                                });
                            }
                            else
                            {
                                CurrentCustomPizza.RemoveTopping("Pineapple");
                            }
                            break;

                        case 5:
                            addRemove = (CurrentCustomPizza.CheckHasTopping("Buffalo Hot Sauce")) ? "Remove" : "Add";
                            System.Console.WriteLine($"Buffalo Hot Sauce {addRemove}ed");
                            if (addRemove == "Add")
                            {
                                CurrentCustomPizza.AddTopping(new Domain.Models.Topping()
                                {
                                    TopName = "Buffalo Hot Sauce", Price = .25
                                });
                            }
                            else
                            {
                                CurrentCustomPizza.RemoveTopping("Buffalo Hot Sauce");
                            }
                            break;

                        case 6:
                            System.Console.WriteLine("Returning to Customize Menu...");
                            menu.currentMenu = 7;
                            break;

                        default:
                            Console.WriteLine("That is not an option");
                            break;
                        }
                    }
                }


                System.Console.WriteLine();
            } while (!terminateProgram);
        }
Example #18
0
        static void Menu(domain.Order cart, domain.User u, domain.Store s, PizzaRepo pr)
        {
            var order = true;

            do
            {
                s.PrintMenu();

                int select;

                int.TryParse(Console.ReadLine(), out select);

                switch (select)
                {
                case 1:
                    pr.CreatePizza(cart.CreatePizza("Cheesy Pizza", "L", "NY Style", new List <string> {
                        "Cheese, Sauce"
                    }), cart, s, u);
                    System.Console.WriteLine("Added Cheese Pizza");
                    break;

                case 2:
                    pr.CreatePizza(cart.CreatePizza("Pepperoni Pizza", "L", "NY Style", new List <string> {
                        "Cheese, Sauce, Pepperoni"
                    }), cart, s, u);
                    System.Console.WriteLine("Added Pepperoni Pizza");
                    break;

                case 3:
                    pr.CreatePizza(cart.CreatePizza("Hawaiian Pizza", "L", "NY Style", new List <string> {
                        "Cheese, Sauce, Pineapple, Ham"
                    }), cart, s, u);
                    System.Console.WriteLine("Added Hawaiian Pizza");
                    break;

                case 4:
                    pr.CreatePizza(cart.CreatePizza("Meat Lovers Pizza", "L", "NY Style", new List <string> {
                        "Cheese, Sauce, Pepperoni, Sausage, Bacon"
                    }), cart, s, u);
                    System.Console.WriteLine("Added Meat Lovers Pizza");
                    break;

                case 5:
                    domain.Pizza custom = cart.CustomPizza();
                    pr.CreatePizza(custom, cart, s, u);
                    System.Console.WriteLine("Added Custom Pizza");
                    break;

                case 6:
                    DisplayCart(cart);
                    break;

                //case 7:
                //EditCart()
                // break;
                case 7:
                    System.Console.WriteLine("Exit Order");
                    order = false;
                    break;
                }
            } while (order);
        }