Esempio n. 1
0
        static void RemovePizza(Order cart)
        {
            System.Console.WriteLine("- Delete a Pizza");
            DisplayCart3(cart);
            Starter.RemovePizzaMenu();

            int select;

            int.TryParse(Console.ReadLine(), out select);
            if (select == 99)
            {
                EditCart(cart);
            }
            cart.RemovePizzaAt(select); // TODO check if there are pizzas to delete
            EditCart(cart);
        }
Esempio n. 2
0
        static void Welcome()
        {
            System.Console.WriteLine("Welcome to PizzaWorld");
            System.Console.WriteLine("Best Pizza in the World");
            System.Console.WriteLine();

            // array
            //1-dimensional
            string[] cart1 = { "", "", "" };       // initial values
            string[] cart2 = new string[3];        // default values
            string[] cart3 = new[] { "", "", "" }; // initial values - custom datatypes or earlier C# versions

            // list
            List <string> cart4 = new List <string> {
                "", "", ""
            };                                         // initial values
            List <string> cart5 = new List <string>(); // default values
            List <Pizza>  cart6 = new List <Pizza>();

            //Menu(cart2);
            //Menu2(cart6);

            var starter = new Starter();
            var user    = new User();
            var store   = new Store();

            //var order = startup.CreateOrder(user, store);
            // if (order != null)
            // {
            //   Menu3(order);
            // }
            // else
            // {
            //   System.Console.WriteLine("technical difficulties, we be back!");
            // }

            try
            {
                Menu(starter.CreateOrder(user, store));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Esempio n. 3
0
        static void Welcome()
        {
            System.Console.WriteLine("Welcome to PizzaWorld");
            System.Console.WriteLine("Best Pizza in the World");
            System.Console.WriteLine();

            var starter = new Starter();
            var user    = new User();
            var store   = new Store();

            try
            {
                Menu(starter.CreateOrder(user, store));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Esempio n. 4
0
        static void AddOrder(Starter starter, User user, Store store)
        {
            var order = new Order();

            try
            {
                order = starter.CreateOrder(user, store);
                ManagePizza.Menu(order);
                var userRepository = new UserRepository();
                userRepository.Create(user);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Whoops, something went wrong!");
                System.Console.WriteLine(ex.Message);
            }
            System.Console.WriteLine("ORDERS: " + user.Orders.Count());
            System.Console.WriteLine();
        }
Esempio n. 5
0
        static void EditPizza(Order cart)
        {
            System.Console.WriteLine("- Edit a Pizza");
            DisplayCart3(cart);
            Starter.EditPizzaMenu();

            int select;

            int.TryParse(Console.ReadLine(), out select);
            if (select == 99)
            {
                EditCart(cart); // going back to menu
            }
            var pizza = cart.Pizzas.ElementAt(select - 1);

            ModifyPizza(pizza);
            DisplayCart3(cart);
            CartMenu(cart);
        }
Esempio n. 6
0
        static void EditSize(Pizza pizza)
        {
            System.Console.WriteLine("- Select Pizza Size");
            Starter.SelectPizzaSizeMenu();
            int select;

            int.TryParse(Console.ReadLine(), out select);
            switch (select)
            {
            case 1:
                pizza.EditPizzaSize("S");
                System.Console.WriteLine("Your Pizza is now Small!");
                break;

            case 2:
                pizza.EditPizzaSize("M");
                System.Console.WriteLine("Your Pizza is now Medium!");
                break;

            case 3:
                pizza.EditPizzaSize("L");
                System.Console.WriteLine("Your Pizza is now Large!");
                break;

            case 4:
                pizza.EditPizzaSize("XL");
                System.Console.WriteLine("Your Pizza is now Extra Large!");
                break;

            case 99:
                System.Console.WriteLine("Returning to Modify Pizza Menu..."); //////////////
                System.Console.WriteLine();
                // ModifyPizza(pizza);
                break;

            default:
                System.Console.WriteLine("Default case");
                System.Console.WriteLine("Returning to Modify Pizza Menu..."); //////////////
                break;
            }
        }
Esempio n. 7
0
        static void CustomerRole()
        {
            System.Console.WriteLine("Do you want to place an order");
            System.Console.WriteLine("or");
            System.Console.WriteLine("view your order history?");
            System.Console.WriteLine();
            var starter = new Starter();
            var user    = new User();
            var store   = new Store();

            do
            {
                Starter.OrderMenu();
                int select;
                int.TryParse(Console.ReadLine(), out select);

                if (select == 1)
                {
                    if (user.Name == null)
                    {
                        System.Console.WriteLine("Please enter a username");
                        string name = Console.ReadLine();
                        user.Name = name;
                    }
                    System.Console.WriteLine("Press Enter to begin your order");
                    Console.ReadLine();
                    AddOrder(starter, user, store);
                }
                else if (select == 2)
                {
                    System.Console.WriteLine("Press Enter to view order history");
                    Console.ReadLine();
                    ViewOrderHistoryByUserId();
                }
                else if (select == 99)
                {
                    return;
                }
            } while (true);
        }
Esempio n. 8
0
            static string GetPizzaCrust(Order cart, ref bool exit)
            {
                var exit1         = false;
                var selection     = 0;
                var crustSelected = "";

                while (!exit && !exit1)
                {
                    Starter.ChooseCrust();

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

                    switch (selection)
                    {
                    case 1:
                        crustSelected = "Thin";
                        System.Console.WriteLine($"You chose {crustSelected}");
                        exit1 = true;
                        break;

                    case 2:
                        crustSelected = "Thick";
                        System.Console.WriteLine($"You chose {crustSelected}");
                        exit1 = true;
                        break;

                    case 3:
                        crustSelected = "Stuffed";
                        System.Console.WriteLine($"You chose {crustSelected}");
                        exit1 = true;
                        break;

                    default:
                        continue;
                    }
                }
                return(crustSelected);
            }
Esempio n. 9
0
            static string GetPizzaSize(Order cart, ref bool exit)
            {
                var exit1        = false;
                var selection    = 0;
                var sizeSelected = "";

                while (!exit && !exit1)
                {
                    Starter.ChooseSize();

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

                    switch (selection)
                    {
                    case 1:
                        sizeSelected = "Regular";
                        System.Console.WriteLine($"You chose {sizeSelected}");
                        exit1 = true;
                        break;

                    case 2:
                        sizeSelected = "Large";
                        System.Console.WriteLine($"You chose {sizeSelected}");
                        exit1 = true;
                        break;

                    case 3:
                        sizeSelected = "Family";
                        System.Console.WriteLine($"You chose {sizeSelected}");
                        exit1 = true;
                        break;

                    default:
                        continue;
                    }
                }
                return(sizeSelected);
            }
Esempio n. 10
0
        public static void Menu()
        {
            bool exit = false;

            /*
             *   add Store selection method here and store the StoreName in the Store object
             */
            while (!exit)
            {
                do
                {
                    Starter.MgmtMenu();

                    int selection;

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

                    switch (selection)
                    {
                    case 1: // Sales History
                        SalesHistory();
                        break;

                    case 2: // Order History
                        OrderHistory();
                        break;

                    default:
                        exit = true;
                        continue;
                    }

                    System.Console.WriteLine();
                    System.Console.WriteLine("Press any key to continue");
                    System.Console.ReadKey();
                } while (!exit);
            }
        }
Esempio n. 11
0
        static void RemoveTopping(Pizza pizza)
        {
            // TODO method should work when user does not want default toppings
            // and user wants to change a topping
            var exit = false;

            do
            {
                System.Console.WriteLine("- Your Toppings");
                DisplayToppings(pizza);
                System.Console.WriteLine("- Remove Topping");
                Starter.RemoveToppingMenu();
                int select;
                int.TryParse(Console.ReadLine(), out select);
                if (select == 99)
                {
                    exit = true;
                    System.Console.WriteLine("Going back to Pizza Menu...");
                    return;
                }
                pizza.RemoveTopping(select);
                System.Console.WriteLine("Topping has been removed");
            } while (!exit);
        }
Esempio n. 12
0
        static void ModifyPizza(Pizza pizza)
        {
            var exit = false;

            do
            {
                System.Console.WriteLine("- Pizza to modify");
                System.Console.WriteLine(pizza);
                System.Console.WriteLine();
                System.Console.WriteLine("- Modify your Pizza");
                Starter.ModifyPizzaMenu();

                int select;
                int.TryParse(Console.ReadLine(), out select);
                switch (select)
                {
                case 1:
                    EditSize(pizza);
                    break;

                case 2:
                    EditCrust(pizza);
                    break;

                case 3:
                    EditToppings(pizza);
                    break;

                case 99:
                    System.Console.WriteLine("Awesome! You are done making changes");
                    System.Console.WriteLine();
                    exit = true;
                    break;
                }
            } while (!exit);
        }
Esempio n. 13
0
            static string GetPizzaType(Order cart, List <string> toppings, decimal price, ref bool exit)
            {
                var    exit1        = false;
                string typeSelected = "";

                // define available Pizza Types
                var pizzaTypes = new string[] { "Cheese", "Pepperoni", "Hawaiian", "Custom" };

                // define standard stopping sets for the above Pizza Types
                Dictionary <string, List <string> > ts = new Dictionary <string, List <string> >();

                ts.Add("Cheese", new List <string> {
                    "cheese"
                });
                ts.Add("Pepperoni", new List <string> {
                    "cheese", "pepperoni"
                });
                ts.Add("Hawaiian", new List <string> {
                    "cheese", "ham", "pineapple"
                });
                ts.Add("Custom", new List <string> {
                    ""
                });

                do
                {
                    Starter.PrintMenu();

                    int selection;

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

                    switch (selection)
                    {
                    case 1: // Cheese
                        toppings.AddRange(ts["Cheese"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 2: // Pepperoni
                        toppings.AddRange(ts["Pepperoni"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 3: // Hawaiian
                        toppings.AddRange(ts["Hawaiian"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 4: // Custom
                            //              toppings.AddRange(ts["Custom"]);
                        AddCustomToppings(toppings);
                        typeSelected = pizzaTypes[selection - 1];
                        var toppings_list = "";
                        toppings_list = String.Join(", ", toppings.ToArray());
                        price         = 9.0m; // fix it for now
                        System.Console.WriteLine($"You chose {typeSelected} with {toppings_list}.");
                        break;

                    case 5:
                        DisplayCart(cart);
                        continue;

                    case 6:

                        // var repository = new PizzaRepository();
                        // Order myOrder = cart;
                        // repository.CreateOrderDb(myOrder);

                        var fmw = new FileManager();
                        fmw.Write(cart);
                        System.Console.WriteLine("Thank you for your order. Goodbye!");
                        exit = true;
                        break;

                    case 7:
                        var fmr = new FileManager();
                        DisplayCart(fmr.Read());
                        break;

                    case 8:
                        exit = true;
                        break;

                    default:
                        break;
                    }

                    System.Console.WriteLine();
                    exit1 = true;
                } while (!exit1);

                return(typeSelected);
            }
Esempio n. 14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter your name");
            string currentUser = Console.ReadLine();
            var    user1       = new User(currentUser);
            var    store1      = new Store();
            var    Starter     = new Starter();
            Order  cart        = Starter.CreateOrder(user1, store1);
            bool   flag        = true;

            while (flag)
            {
                flag = newInput();
            }
            bool newInput()
            {
                Console.WriteLine("type cheese if you want top add a cheese pizza to the cart");
                Console.WriteLine("type peperoni if you want peperoni");
                Console.WriteLine("type sausage if you want suasage");
                Console.WriteLine("type custom if you want a custom pizza");
                Console.WriteLine("type cart to display the cart");
                Console.WriteLine("type past to display the past orders");
                Console.WriteLine("type total to see your total");
                Console.WriteLine("press enter if you want to exit");
                var   temp        = new PizzaStore.Client.Starter();
                var   SaveManager = new SaveManager();
                Pizza tempPizza;

                switch (Console.ReadLine())
                {
                case "cheese":
                    tempPizza = new Pizza("L", "thick", new List <string> {
                        "cheese"
                    }, 10.00);
                    cart.pizzas.Add(tempPizza);
                    break;

                case "pepperoni":
                    tempPizza = new Pizza("L", "thick", new List <string> {
                        "Pepperoni"
                    }, 13.00);
                    cart.pizzas.Add(tempPizza);
                    break;

                case "suasage":
                    tempPizza = new Pizza("L", "thick", new List <string> {
                        "Suasage"
                    }, 14.00);
                    cart.pizzas.Add(tempPizza);
                    break;

                case "custom":
                    tempPizza = new Pizza("L", "thick", custom(), 16.00);
                    cart.pizzas.Add(tempPizza);
                    break;

                case "past":
                    var pastCart = SaveManager.Read(currentUser);
                    foreach (Pizza x in pastCart.pizzas)
                    {
                        Console.WriteLine($"{x.ToString()}");
                    }
                    break;

                case "cart":
                    foreach (Pizza x in cart.pizzas)
                    {
                        Console.WriteLine($"{x.ToString()}");
                    }
                    break;

                case "Total":
                    double tempTotal = 0;
                    foreach (Pizza x in cart.pizzas)
                    {
                        tempTotal += x.Cost;
                    }
                    Console.WriteLine($"your total is: {tempTotal}");
                    break;

                default:
                    SaveManager.Write(cart, currentUser);
                    return(false);
                }
                return(true);//returns the result of the operation
            }

            List <string> custom()
            {
                bool          flag        = true;
                List <string> customPizza = new List <string>();
                int           customIndex = 0;

                while (flag)
                {
                    Console.WriteLine("you may only add three toppingsto your pizza");
                    Console.WriteLine("type cheese if you want top add a cheese pizza to the cart");
                    Console.WriteLine("type peperoni if you want peperoni");
                    Console.WriteLine("type sausage if you want suasage");
                    Console.WriteLine("press enter if you want to exit");

                    switch (Console.ReadLine())
                    {
                    case "cheese":
                        customPizza.Add("cheese");
                        break;

                    case "pepperoni":
                        customPizza.Add("Pepperoni");
                        break;

                    case "suasage":
                        customPizza.Add("suasage");
                        break;

                    default:
                        flag = false;
                        break;
                    }
                    if (customIndex == 3)
                    {
                        flag = false;
                    }
                }
                return(customPizza);
            }
        }
Esempio n. 15
0
            static string GetPizzaType(Order cart, List <string> toppings, ref bool exit)
            {
                var    exit1        = false;
                string typeSelected = "";

                // define available Pizza Types
                var pizzaTypes = new string[] { "Cheese", "Pepperoni", "Hawaiian", "Custom" };

                // define standard stopping sets for the above Pizza Types
                Dictionary <string, List <string> > ts = new Dictionary <string, List <string> >();

                ts.Add("Cheese", new List <string> {
                    "cheese"
                });
                ts.Add("Pepperoni", new List <string> {
                    "cheese", "pepperoni"
                });
                ts.Add("Hawaiian", new List <string> {
                    "cheese", "ham", "pineapple"
                });
                ts.Add("Custom", new List <string> {
                    ""
                });

                do
                {
                    Starter.PrintMenu();

                    int selection;

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

                    switch (selection)
                    {
                    case 1: // Cheese
                        toppings.AddRange(ts["Cheese"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 2: // Pepperoni
                        toppings.AddRange(ts["Pepperoni"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 3: // Hawaiian
                        toppings.AddRange(ts["Hawaiian"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 4: // Custom
                        toppings.AddRange(ts["Custom"]);
                        typeSelected = pizzaTypes[selection - 1];
                        System.Console.WriteLine($"You chose {typeSelected}");
                        break;

                    case 5:
                        DisplayCart(cart);
                        continue;

                    case 6:
                        var fmw = new FileManager();
                        fmw.Write(cart);
                        System.Console.WriteLine("Thank you for your order. Goodbye!");
                        exit = true;
                        break;

                    case 7:
                        var fmr = new FileManager();
                        DisplayCart(fmr.Read());
                        break;

                    default:
                        break;
                    }

                    System.Console.WriteLine();
                    exit1 = true;
                } while (!exit1);

                return(typeSelected);
            }
Esempio n. 16
0
        // entrypoint to user story
        public static void UserOptions(User user)
        {
            var exit = false;

            do
            {
                System.Console.WriteLine("\nHow can we help you today?");
                System.Console.WriteLine("1: Order pizzas");
                System.Console.WriteLine("2: View your order history");
                System.Console.WriteLine("3: Exit");

                int selection;
                System.Console.Write("Your selection: ");
                int.TryParse(Console.ReadLine(), out selection);

                switch (selection)
                {
                // order pizzas option
                case 1:
                    var storeList = _db.ReadAllStores();     // read stores from database

                    System.Console.WriteLine("\nWhich store would you like to order from?");
                    for (int i = 0; i < storeList.Count; i++)
                    {
                        System.Console.WriteLine($"{i + 1}: {storeList[i].Name}");
                    }

                    int storeId;
                    System.Console.Write("Your selection: ");
                    int.TryParse(Console.ReadLine(), out storeId);

                    var store = storeList[storeId - 1];     // select a store to order from
                    store.Toppings.AddRange(_db.ReadToppings());
                    store.Sizes.AddRange(_db.ReadSizes());
                    store.Crusts.AddRange(_db.ReadCrusts());
                    store.PizzaPresets.AddRange(Starter.GeneratePresets());

                    System.Console.WriteLine($"\nOrdering from {store.Name}");

                    var order = store.CreateOrder(user);     // create an order
                    System.Console.WriteLine();

                    try
                    {
                        OrderPizzas(order, user, store);     // begin ordering pizzas
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.Message);
                    }
                    break;

                // view order history for user
                case 2:
                    ViewOrderHistory(user);
                    break;

                // exit application
                case 3:
                    exit = true;
                    System.Console.WriteLine("\nThank you, have a good day!");
                    break;
                }
            } while (!exit);
        }
Esempio n. 17
0
        // static void Menu(string[] cart)
        // {
        //   var exit = false;
        //   var number = 0;

        //   do
        //   {
        //     if (number < cart.Length)
        //     {
        //       System.Console.WriteLine("Select 1 for Cheese Pizza");
        //       System.Console.WriteLine("Select 2 for Pepperoni Pizza");
        //       System.Console.WriteLine("Select 3 for Pineapple Pizza");
        //       System.Console.WriteLine("Select 4 for Custom Pizza");
        //       System.Console.WriteLine("Select 5 for Show Cart");
        //       System.Console.WriteLine("Select 6 for Exit");
        //       System.Console.WriteLine();

        //       int select;

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

        //       switch (select)
        //       {
        //         case 1:
        //           cart[number] = "cheese";
        //           number += 1;
        //           System.Console.WriteLine("added Cheese");
        //           break;
        //         case 2:
        //           cart[number] = "pepperoni";
        //           number += 1;
        //           System.Console.WriteLine("added Pepperoni");
        //           break;
        //         case 3:
        //           cart[number] = "pineapple";
        //           number += 1;
        //           System.Console.WriteLine("added Pineapple");
        //           break;
        //         case 4:
        //           cart[number] = "custom";
        //           number += 1;
        //           System.Console.WriteLine("added Custom");
        //           break;
        //         case 5:
        //           DisplayCart(cart);
        //           break;
        //         case 6:
        //           System.Console.WriteLine("thank you, goodbye!");
        //           exit = true;
        //           break;
        //       }
        //     }
        //     else
        //     {
        //       DisplayCart(cart);
        //       exit = true;
        //     }
        //   } while (!exit);
        // }

        // static void Menu2(List<Pizza> cart)
        // {
        //   var exit = false;
        //   var number = 0;
        //   var startup = new PizzaStore.Client.Startup();

        //   do
        //   {
        //     if (number < 10)
        //     {
        //       System.Console.WriteLine("Select 1 for Cheese Pizza");
        //       System.Console.WriteLine("Select 2 for Pepperoni Pizza");
        //       System.Console.WriteLine("Select 3 for Pineapple Pizza");
        //       System.Console.WriteLine("Select 4 for Custom Pizza");
        //       System.Console.WriteLine("Select 5 for Show Cart");
        //       System.Console.WriteLine("Select 6 for Exit");
        //       System.Console.WriteLine();

        //       int select;

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

        //       switch (select)
        //       {
        //         case 1:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"cheese"}));
        //           number += 1;
        //           System.Console.WriteLine("added Cheese");
        //           break;
        //         case 2:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"pepperoni"}));
        //           number += 1;
        //           System.Console.WriteLine("added Pepperoni");
        //           break;
        //         case 3:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"pineapple"}));
        //           number += 1;
        //           System.Console.WriteLine("added Pineapple");
        //           break;
        //         case 4:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"custom"}));
        //           number += 1;
        //           System.Console.WriteLine("added Custom");
        //           break;
        //         case 5:
        //           DisplayCart2(cart);
        //           break;
        //         case 6:
        //           System.Console.WriteLine("thank you, goodbye!");
        //           exit = true;
        //           break;
        //       }
        //     }
        //     else
        //     {
        //       DisplayCart2(cart);
        //       exit = true;
        //     }

        //     System.Console.WriteLine();
        //   } while (!exit);
        // }

        // static void DisplayCart(string[] cart)
        // {
        //   foreach (var pizza in cart)
        //   {
        //     System.Console.WriteLine(pizza);
        //   }
        // }

        // static void DisplayCart2(List<Pizza> cart)
        // {
        //   foreach (var pizza in cart)
        //   {
        //     System.Console.WriteLine(pizza);
        //   }
        // }

        static void Menu(Order cart)
        {
            var exit = false;

            do
            {
                Starter.PrintMenu();

                int select;

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

                switch (select)
                {
                case 1:
                    cart.CreatePizza("L", "Deep Dish Crust", new List <string> {
                        "Cheese"
                    });
                    Console.WriteLine("Cheese Pizza Added To Cart\n");
                    break;

                case 2:
                    cart.CreatePizza("L", "Pan Crust", new List <String> {
                        "Cheese, Pepperoni"
                    });
                    Console.WriteLine("Pepperoni Pizza Added To Cart\n");
                    break;

                case 3:
                    cart.CreatePizza("L", "Thin Crust", new List <String> {
                        "Cheese, Sausage"
                    });
                    Console.WriteLine("Sausage Pizza Added To Cart\n");
                    break;

                case 4:
                    cart.CreatePizza("L", "Stuffed Crust", new List <String> {
                        "Cheese, Pepperoni, Sausage, Onions, Bell Peppers, Olives"
                    });
                    Console.WriteLine("Custom Pizza Added To Cart\n");
                    break;

                case 5:
                    DisplayCart(cart);
                    break;

                case 6:
                    var fmw = new FileManager();
                    fmw.Write(cart);
                    System.Console.WriteLine("Thanks for visiting!\nSee you next time!");
                    exit = true;
                    break;

                case 7:
                    var fmr = new FileManager();
                    DisplayCart(fmr.Read());
                    break;
                }

                System.Console.WriteLine();
            } while (!exit);
        }
Esempio n. 18
0
        /*
         * static void Menu(string[] cart)
         * {
         *
         * var exit = false;
         * var number = 0;
         *
         * do
         * {
         *
         *  if (number < cart.Length)
         *  {
         *    Console.WriteLine("Select 1 for Cheese Pizza");
         *    Console.WriteLine("Select 2 for Pepperoni Pizza");
         *    Console.WriteLine("Select 3 for Hawaiian Pizza");
         *    Console.WriteLine("Select 4 for Custom Pizza");
         *    Console.WriteLine("Select 5 to see cart");
         *    Console.WriteLine("Select 6 for Exit");
         *    Console.WriteLine();
         *
         *
         *    int select;
         *    int.TryParse(Console.ReadLine(), out select);
         *
         *    switch (select)
         *    {
         *      case 1:
         *        cart[number] = "cheese";
         *        number += 1;
         *        Console.WriteLine("added Cheese Pizza");
         *        break;
         *      case 2:
         *        cart[number] = "pepperoni";
         *        number += 1;
         *        Console.WriteLine("added Pepperoni Pizza");
         *        break;
         *      case 3:
         *        cart[number] = "Hawaiian";
         *        number += 1;
         *        Console.WriteLine("added Hawaiian Pizza");
         *        break;
         *      case 4:
         *        cart[number] = "custom";
         *        number += 1;
         *        Console.WriteLine("added Custom Pizza");
         *        break;
         *      case 5:
         *        DisplayCart(cart);
         *        break;
         *      case 6:
         *        Console.WriteLine("Thank you!");
         *        exit = true;
         *        break;
         *    }
         *  }
         *  else
         *  {
         *    DisplayCart(cart);
         *    exit = true;
         *  }
         *
         *  Console.WriteLine();
         * } while (!exit);
         * }
         *
         *
         * static void DisplayCart(string[] cart)
         * {
         * Console.WriteLine("Your Order:");
         * foreach (var pizza in cart)
         * {
         *  Console.WriteLine(pizza);
         * }
         *
         * }
         *
         */

        //     *****list****

        /* static void DisplayCart2(List<string> cart)
         * {
         * System.Console.WriteLine("Your Order:");
         * foreach (var pizza in cart)
         * {
         *  System.Console.WriteLine(pizza);
         * }
         *
         * } */

        /*   static void DisplayCart2(List<Pizza> cart)
         * {
         *  System.Console.WriteLine("Your Order:");
         *  foreach (var pizza in cart)
         *  {
         *    System.Console.WriteLine(pizza);
         *  }
         * } */
        static void Menu3(Order cart)
        {
            var exit = false;

            do
            {
                Starter.PrintMenu();

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

                switch (select)
                {
                case 1:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "cheese"
                    });
                    Console.WriteLine("added Cheese Pizza");
                    break;

                case 2:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "pepperoni"
                    });
                    Console.WriteLine("added Pepperoni Pizza");
                    break;

                case 3:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "Hawaiian"
                    });
                    Console.WriteLine("added Hawaiian Pizza");
                    break;

                case 4:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "custom"
                    });
                    Console.WriteLine("added Custom Pizza");
                    break;

                case 5:
                    DisplayCart3(cart);
                    break;

                case 6:
                    var fmw = new FileManager();
                    fmw.Write(cart);
                    Console.WriteLine("Thank you!");
                    exit = true;
                    break;

                case 7:
                    var fmr = new FileManager();
                    DisplayCart3(fmr.Read());
                    break;
                }

                Console.WriteLine();
            } while (!exit);
        }
        static void Main(string[] args)
        {
            string ModeSwitch()
            {
                Console.WriteLine("please enter store if you wish to continue as as store or user to continue as a user");
                switch (Console.ReadLine())
                {
                case "store":
                    return("store");

                case "user":
                    return("user");

                default:
                    return(ModeSwitch());
                }
            }

            PIZZASTORE2Context dbo = new PIZZASTORE2Context();

            CL.Store        currentStore    = new CL.Store("temp");
            List <CL.Store> availableStores = new List <CL.Store>();

            {
                foreach (var s in dbo.Store2.ToList())
                {
                    var tempStore = new CL.Store(s.Name);
                    var tempID    = -1;
                    foreach (var oj in dbo.OrderJunction2)
                    {
                        if (oj.StoreId == s.StoreId)
                        {
                            tempID = (int)oj.OrderId;
                        }
                        foreach (var o in dbo.Order2)
                        {
                            if (tempID == o.OrderId)
                            {
                                var tempOrder = new CL.Order();

                                foreach (var poj in dbo.PizzaOrderJunction2.ToList())
                                {
                                    if (tempID == poj.OrderId)
                                    {
                                        List <string> toppings = new List <string>();
                                        foreach (var pj in dbo.PizzaJunction2.ToList())
                                        {
                                            if (pj.PizzaId == poj.PizzaId)
                                            {
                                                foreach (var t in dbo.Toppings2)
                                                {
                                                    if (pj.ToppingsId == t.ToppingsId)
                                                    {
                                                        toppings.Add(t.Name);
                                                    }
                                                }
                                            }
                                            var       pizzaName = "";
                                            DB.Crust2 dbCrust   = new Crust2();
                                            DB.Size2  dbSize    = new Size2();
                                            foreach (var p in dbo.Pizza2)
                                            {
                                                if (p.PizzaId == poj.PizzaId)
                                                {
                                                    pizzaName = p.Name;
                                                    foreach (var c in dbo.Crust2)
                                                    {
                                                        if (c.CrustId == p.CrustId)
                                                        {
                                                            dbCrust = c;
                                                        }
                                                    }
                                                    foreach (var si in dbo.Size2)
                                                    {
                                                        if (si.SizeId == p.SizeId)
                                                        {
                                                            dbSize = si;
                                                        }
                                                    }
                                                }
                                            }

                                            var tempPizza = new Pizza(new CL.Crust(dbCrust.Name), new CL.Size(dbSize.Size), new CL.Toppings(toppings), pizzaName);
                                            tempOrder.pizzas.Add(tempPizza);
                                        }


                                        tempStore.orders.Add(tempOrder);
                                    }
                                }
                                availableStores.Add(tempStore);
                            }
                        }
                    }
                }
            }
            if (ModeSwitch() == "store")
            {
                var flag = true;
                Console.WriteLine("selct your store");
                var inputName = Console.ReadLine();
                foreach (CL.Store a in availableStores)
                {
                    if (a.Name == inputName)
                    {
                        currentStore = a;
                        flag         = false;
                    }
                }
                if (flag)
                {
                    currentStore = new CL.Store(inputName);
                    DB.Store2 dbStore = new Store2();
                    dbStore.Name = inputName;
                    dbo.Store2.Add(dbStore);
                    dbo.SaveChanges();
                }
                Console.WriteLine("type sales to see sales");
                Console.WriteLine("type orders to see orders");
                Console.WriteLine("press enter top exit");
                switch (Console.ReadLine())
                {
                default:
                    break;
                }
            }

            else
            {
                Console.WriteLine("Please enter username");
                string currentUsername = Console.ReadLine();
                var    currentUser     = new PizzaStore.Domain.User(currentUsername);
                Console.WriteLine("please select a pizza store");
                foreach (var ast in availableStores)
                {
                    Console.WriteLine($"type {ast.Name} to select {ast.Name} as the resteraunt you want to go to.");
                }
                var currentStoreName = Console.ReadLine();
                currentStore = new CL.Store(currentStoreName);
                foreach (var ast in availableStores)
                {
                    if (ast.Name == currentStoreName)
                    {
                        currentStore = ast;
                    }
                }

                foreach (var u in dbo.User2.ToList())
                {
                    if (u.Name == currentUsername)
                    {
                        currentUser.Name = currentUsername;
                        foreach (var oj2 in dbo.OrderJunction2)
                        {
                            var tempID = -1;
                            if (oj2.UserId == u.UserId)
                            {
                                tempID = (int)oj2.OrderId;
                            }
                            foreach (var o in dbo.Order2)
                            {
                                if (tempID == o.OrderId)
                                {
                                    var tempOrder = new CL.Order();

                                    foreach (var poj in dbo.PizzaOrderJunction2.ToList())
                                    {
                                        if (tempID == poj.OrderId)
                                        {
                                            List <string> toppings = new List <string>();
                                            foreach (var pj in dbo.PizzaJunction2.ToList())
                                            {
                                                if (pj.PizzaId == poj.PizzaId)
                                                {
                                                    foreach (var t in dbo.Toppings2)
                                                    {
                                                        if (pj.ToppingsId == t.ToppingsId)
                                                        {
                                                            toppings.Add(t.Name);
                                                        }
                                                    }
                                                }
                                                var       pizzaName = "";
                                                DB.Crust2 dbCrust   = new Crust2();
                                                DB.Size2  dbSize    = new Size2();
                                                foreach (var p in dbo.Pizza2)
                                                {
                                                    if (p.PizzaId == poj.PizzaId)
                                                    {
                                                        pizzaName = p.Name;
                                                        foreach (var c in dbo.Crust2)
                                                        {
                                                            if (c.CrustId == p.CrustId)
                                                            {
                                                                dbCrust = c;
                                                            }
                                                        }
                                                        foreach (var si in dbo.Size2)
                                                        {
                                                            if (si.SizeId == p.SizeId)
                                                            {
                                                                dbSize = si;
                                                            }
                                                        }
                                                    }
                                                }

                                                var tempPizza = new Pizza(new CL.Crust(dbCrust.Name), new CL.Size(dbSize.Size), new CL.Toppings(toppings), pizzaName);
                                                tempOrder.pizzas.Add(tempPizza);
                                            }
                                        }
                                        currentUser.orders.Add(tempOrder);
                                    }
                                }
                            }
                        }
                    }
                }


                var Starter = new Starter();
                PizzaStore.Domain.Order cart = Starter.CreateOrder(currentUser, currentStore);

                bool flag = true;
                while (flag)
                {
                    flag = newInput(cart, currentUser, currentStoreName);
                }
            }
            bool newInput(CL.Order cart, CL.User currentUser, string currentStoreName)
            {
                Console.WriteLine("type cheese if you want to add a cheese pizza to the cart");
                Console.WriteLine("type peperoni if you want peperoni");
                Console.WriteLine("type sausage if you want suasage");
                Console.WriteLine("type custom if you want a custom pizza");
                Console.WriteLine("type cart to display the cart");
                Console.WriteLine("type past to display the past orders");
                Console.WriteLine("type total to see your total");
                Console.WriteLine("type delete to delete a pizza");
                Console.WriteLine("press enter if you want to exit");
                var   temp = new PizzaStore.Client.Starter();
                Pizza tempPizza;

                switch (Console.ReadLine())
                {
                case "cheese":
                    tempPizza = new Pizza(GetCrust(), GetSize(), new CL.Toppings(new List <string> {
                        "Cheese"
                    }), "cheese");
                    cart.pizzas.Add(tempPizza);
                    break;

                case "pepperoni":
                    tempPizza = new Pizza(GetCrust(), GetSize(), new CL.Toppings(new List <string> {
                        "Pepperoni"
                    }), "pepperoni");
                    cart.pizzas.Add(tempPizza);
                    break;

                case "suasage":
                    tempPizza = new Pizza(GetCrust(), GetSize(), new CL.Toppings(new List <string> {
                        "Suasage"
                    }), "suasage");
                    cart.pizzas.Add(tempPizza);
                    break;

                case "custom":
                    tempPizza = new Pizza(GetCrust(), GetSize(), custom(), "custom");
                    cart.pizzas.Add(tempPizza);
                    break;

                case "past":
                    var pastCart = currentUser;
                    foreach (CL.Order O in pastCart.orders)
                    {
                        foreach (CL.Pizza p in O.pizzas)
                        {
                            Console.WriteLine($"{p.ToString()}");
                        }
                    }
                    break;

                case "cart":
                    foreach (Pizza x in cart.pizzas)
                    {
                        Console.WriteLine($"{x.ToString()}");
                    }
                    break;

                case "total":
                    double tempTotal = 0;
                    foreach (Pizza x in cart.pizzas)
                    {
                        tempTotal += x.Price;
                    }
                    Console.WriteLine($"your total is: {tempTotal}");
                    break;

                case "delete":
                    deletePizza(cart);
                    break;

                default:

                    DB.User2  dbUser     = new DB.User2();
                    var       userExists = false;
                    DB.Store2 dbStore    = new DB.Store2();
                    {
                        foreach (var p in dbo.User2.ToList())
                        {
                            var tempName = p.Name;
                            if (tempName == currentUser.Name)
                            {
                                dbUser     = p;
                                userExists = true;
                            }
                        }
                        if (!userExists)
                        {
                            dbUser.Name = currentUser.Name;
                            dbo.User2.Add(dbUser);
                            dbo.SaveChanges();
                        }
                    }
                    foreach (var st in dbo.Store2.ToList())
                    {
                        if (st.Name == currentStoreName)
                        {
                            dbStore = st;
                        }
                    }

                    DB.Order2 dbCart = new DB.Order2();
                    dbo.SaveChanges();
                    dbo.Order2.Add(dbCart);
                    DB.OrderJunction2 dbOrderJunction = new OrderJunction2();
                    dbOrderJunction.Order = dbCart;
                    dbOrderJunction.User  = dbUser;
                    dbo.OrderJunction2.Add(dbOrderJunction);

                    foreach (Pizza P in cart.pizzas)
                    {
                        var       crustExists = false;
                        var       sizeExists  = false;
                        DB.Crust2 tempCrust   = new Crust2();
                        tempCrust.Name = P.Crust.Name;
                        DB.Size2 tempSize = new Size2();
                        tempSize.Size = P.Size.size;
                        DB.Pizza2 dbPizza = new Pizza2();
                        dbPizza.Name = P.Name;

                        foreach (var c in dbo.Crust2.ToList())
                        {
                            if (c.Name == P.Crust.Name)
                            {
                                dbPizza.CrustId = c.CrustId;
                                crustExists     = true;
                            }
                        }
                        if (!crustExists)
                        {
                            dbPizza.Crust = tempCrust;
                        }

                        foreach (var si in dbo.Size2.ToList())
                        {
                            if (si.Size == P.Size.size)
                            {
                                dbPizza.SizeId = si.SizeId;
                                sizeExists     = true;
                            }
                        }
                        if (!sizeExists)
                        {
                            dbPizza.Size = tempSize;
                        }
                        dbo.Pizza2.Add(dbPizza);
                        dbo.Size2.Add(tempSize);
                        dbo.Crust2.Add(tempCrust);



                        DB.PizzaOrderJunction2 POJ = new PizzaOrderJunction2();
                        POJ.Order = dbCart;
                        POJ.Pizza = dbPizza;
                        dbo.PizzaOrderJunction2.Add(POJ);

                        foreach (var t in P.Toppings.Content)
                        {
                            DB.PizzaJunction2 PJ = new PizzaJunction2();
                            PJ.Pizza = dbPizza;
                            var toppingExists = false;
                            foreach (var dbT in dbo.Toppings2)
                            {
                                if (dbT.Name == t)
                                {
                                    PJ.Toppings = dbT;

                                    toppingExists = true;
                                }
                            }
                            if (!toppingExists)
                            {
                                DB.Toppings2 tempToppings = new Toppings2();
                                tempToppings.Name = t;
                                dbo.Add(tempToppings);
                                PJ.Toppings = tempToppings;
                            }
                            dbo.Add(PJ);
                        }
                    }

                    dbo.SaveChanges();



                    return(false);
                }
                return(true);       //returns the result of the operation
            }

            CL.Toppings custom()
            {
                bool          flag        = true;
                List <string> customPizza = new List <string>();
                int           customIndex = 0;

                while (flag)
                {
                    Console.WriteLine("you may only add four toppingsto your pizza");
                    Console.WriteLine("type cheese if you want top add a cheese pizza to the cart");
                    Console.WriteLine("type peperoni if you want peperoni");
                    Console.WriteLine("type sausage if you want suasage");
                    Console.WriteLine("press enter if you want to exit");

                    switch (Console.ReadLine())
                    {
                    case "cheese":
                        customPizza.Add("cheese");
                        customIndex += 1;
                        break;

                    case "pepperoni":
                        customPizza.Add("Pepperoni");
                        customIndex += 1;
                        break;

                    case "suasage":
                        customPizza.Add("suasage");
                        customIndex += 1;
                        break;

                    default:
                        flag = false;
                        break;
                    }
                    if (customIndex == 4)
                    {
                        flag = false;
                    }
                }
                return(new CL.Toppings(customPizza));
            }

            PizzaStore.Domain.Crust GetCrust()
            {
                Console.WriteLine("type thin if you want a thin crust");
                Console.WriteLine("type thick if you want a thick crust");
                Console.WriteLine("type garlic if you want a garlic crust");
                switch (Console.ReadLine())
                {
                case "thin":
                    return(new CL.Crust("thin"));


                case "thick":
                    return(new CL.Crust("thick"));


                case "garlic":
                    return(new CL.Crust("garlic"));

                default:
                    return(GetCrust());
                }
            }

            CL.Size GetSize()
            {
                Console.WriteLine("type small or 12  if you want a small pizza");
                Console.WriteLine("type medium or 14 if you want a medium pizza");
                Console.WriteLine("type large  or 16 if you want a large pizza");
                Console.WriteLine("type 21 or extralarge if you want a large pizza");
                switch (Console.ReadLine())
                {
                case "small":
                case "12":
                    return(new CL.Size("small"));


                case "medium":
                case "14":
                    return(new CL.Size("medium"));


                case "large":
                case "16":
                    return(new CL.Size("large"));


                case "extralarge":
                case "21":
                    return(new CL.Size("extralarge"));


                default:
                    return(GetSize());
                }
            }

            void deletePizza(CL.Order cart)
            {
                foreach (Pizza p in cart.pizzas)
                {
                    Console.WriteLine($" {p.ToString()}");
                    Console.WriteLine("delete this pizza(y/n)?");
                    if (Console.ReadLine() == "y")
                    {
                        cart.pizzas.Remove(p);
                    }
                }
            }
        }
Esempio n. 20
0
        // static void Menu(string[] cart)
        // {
        //   var exit = false;
        //   var number = 0;

        //   do
        //   {
        //     if (number < cart.Length)
        //     {
        //       System.Console.WriteLine("Select 1 for Cheese Pizza");
        //       System.Console.WriteLine("Select 2 for Pepperoni Pizza");
        //       System.Console.WriteLine("Select 3 for Pineapple Pizza");
        //       System.Console.WriteLine("Select 4 for Custom Pizza");
        //       System.Console.WriteLine("Select 5 for Show Cart");
        //       System.Console.WriteLine("Select 6 for Exit");
        //       System.Console.WriteLine();

        //       int select;

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

        //       switch (select)
        //       {
        //         case 1:
        //           cart[number] = "cheese";
        //           number += 1;
        //           System.Console.WriteLine("added Cheese");
        //           break;
        //         case 2:
        //           cart[number] = "pepperoni";
        //           number += 1;
        //           System.Console.WriteLine("added Pepperoni");
        //           break;
        //         case 3:
        //           cart[number] = "pineapple";
        //           number += 1;
        //           System.Console.WriteLine("added Pineapple");
        //           break;
        //         case 4:
        //           cart[number] = "custom";
        //           number += 1;
        //           System.Console.WriteLine("added Custom");
        //           break;
        //         case 5:
        //           DisplayCart(cart);
        //           break;
        //         case 6:
        //           System.Console.WriteLine("thank you, goodbye!");
        //           exit = true;
        //           break;
        //       }
        //     }
        //     else
        //     {
        //       DisplayCart(cart);
        //       exit = true;
        //     }
        //   } while (!exit);
        // }

        // static void Menu2(List<Pizza> cart)
        // {
        //   var exit = false;
        //   var number = 0;
        //   var startup = new PizzaStore.Client.Startup();

        //   do
        //   {
        //     if (number < 10)
        //     {
        //       System.Console.WriteLine("Select 1 for Cheese Pizza");
        //       System.Console.WriteLine("Select 2 for Pepperoni Pizza");
        //       System.Console.WriteLine("Select 3 for Pineapple Pizza");
        //       System.Console.WriteLine("Select 4 for Custom Pizza");
        //       System.Console.WriteLine("Select 5 for Show Cart");
        //       System.Console.WriteLine("Select 6 for Exit");
        //       System.Console.WriteLine();

        //       int select;

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

        //       switch (select)
        //       {
        //         case 1:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"cheese"}));
        //           number += 1;
        //           System.Console.WriteLine("added Cheese");
        //           break;
        //         case 2:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"pepperoni"}));
        //           number += 1;
        //           System.Console.WriteLine("added Pepperoni");
        //           break;
        //         case 3:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"pineapple"}));
        //           number += 1;
        //           System.Console.WriteLine("added Pineapple");
        //           break;
        //         case 4:
        //           cart.Add(startup.CreatePizza("L", "Stuffed", new List<string>{"custom"}));
        //           number += 1;
        //           System.Console.WriteLine("added Custom");
        //           break;
        //         case 5:
        //           DisplayCart2(cart);
        //           break;
        //         case 6:
        //           System.Console.WriteLine("thank you, goodbye!");
        //           exit = true;
        //           break;
        //       }
        //     }
        //     else
        //     {
        //       DisplayCart2(cart);
        //       exit = true;
        //     }

        //     System.Console.WriteLine();
        //   } while (!exit);
        // }

        // static void DisplayCart(string[] cart)
        // {
        //   foreach (var pizza in cart)
        //   {
        //     System.Console.WriteLine(pizza);
        //   }
        // }

        // static void DisplayCart2(List<Pizza> cart)
        // {
        //   foreach (var pizza in cart)
        //   {
        //     System.Console.WriteLine(pizza);
        //   }
        // }

        static void Menu(Order cart)
        {
            var exit = false;

            do
            {
                Starter.PrintMenu();

                int select;

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

                switch (select)
                {
                case 1:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "cheese"
                    });
                    System.Console.WriteLine("added Cheese");
                    break;

                case 2:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "pepperoni"
                    });
                    System.Console.WriteLine("added Pepperoni");
                    break;

                case 3:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "pineapple"
                    });
                    System.Console.WriteLine("added Pineapple");
                    break;

                case 4:
                    cart.CreatePizza("L", "Stuffed", new List <string> {
                        "custom"
                    });
                    System.Console.WriteLine("added Custom");
                    break;

                case 5:
                    DisplayCart(cart);
                    break;

                case 6:
                    var fmw = new FileManager();
                    fmw.Write(cart);
                    System.Console.WriteLine("thank you, goodbye!");
                    exit = true;
                    break;

                case 7:
                    var fmr = new FileManager();
                    DisplayCart(fmr.Read());
                    break;
                }

                System.Console.WriteLine();
            } while (!exit);
        }