/// <summary>
        /// Allow the user an opportunity to back out of a pizza, not the entire order.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="HawaiiPizza"></param>
        /// <returns></returns>
        public static bool PizzaConfirmToOrder(string username, string storeName, Pizza PizzaChoice)
        {
            int confirm = -1;

            while (!(confirm >= 1 && confirm <= 2))
            {
                ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                Console.WriteLine(" | %%% Price of pizza adding to order: ${0} %%%|", PizzaChoice.getPriceOfPizza());
                Console.WriteLine(" |---------------------------------------------------------");
                Console.WriteLine(" |1. : Confirm Pizza to order");
                Console.WriteLine(" |2. : return to previous menu...");
                Console.WriteLine(" |_________________________________________________________");

                confirm = IntCheck.IntChecker();
                if (confirm == -1)
                {
                    continue;
                }

                if (confirm == 1)
                {
                    return(true);
                }
                if (confirm == 2)
                {
                    return(false);
                }
                else
                {
                    Console.WriteLine("Not an option");
                    confirm = -1;
                }
            }
            return(false);
        }
        /// <summary>
        /// Get through the sign in process.
        /// </summary>
        //public int SignInToAccount(Dictionary<string, string> UserList, Pizza pizza, StoreRepository stores,
        public int SignInToAccount(
            Abstractions.IRepositoryCustomer <Customer1> repo,
            Abstractions.IRepositoryOrders <Order1> orderRepo,
            Abstractions.IRepositoryPizza <Pizza1> pizzaRepo,
            Abstractions.IRepositoryStore <Store1> storeRepo)
        {
            int choice = 1;

            while (choice != 0)
            {
                Console.Clear();
                Console.WriteLine(" __________________________________");
                Console.WriteLine(" |1\tSign In?");
                Console.WriteLine(" |2\tCreate New Account?");
                Console.WriteLine(" |0\t<Close Program>");
                Console.WriteLine(" |_________________________________");

                choice = IntCheck.IntChecker();
                if (choice == -1)
                {
                    continue;
                }

                //ask for user name and password of a previously created account
                if (choice == 1)
                {
                    string name = Login.LoginUserPrompt.LoginUserPrompter(repo);
                    if (!name.Equals("@"))
                    {
                        _b_LocationOrderHistory.ChooseVewOrdersOrStorePortal(name, repo, orderRepo, pizzaRepo, storeRepo);
                    }
                }

                //ask for user to create new acount by giving a email and password
                else if (choice == 2)
                {
                    Login.CreateNewUser.CreateNewUserPrompt(repo);
                }
            }

            Console.WriteLine("Thank you!");
            return(choice);
        }
        //public void ChooseVewOrdersOrStorePortal(string username, StoreRepository stores, OrderHistory orderHistory,
        public static void ChooseVewOrdersOrStorePortal(string username,
                                                        Abstractions.IRepositoryCustomer <Customer1> repo,
                                                        Abstractions.IRepositoryOrders <Order1> orderRepo,
                                                        Abstractions.IRepositoryPizza <Pizza1> pizzaRepo,
                                                        Abstractions.IRepositoryStore <Store1> storeRepo)
        {
            int signedInChoice = 0;

            while (signedInChoice != 3)
            {
                HeaderPortal.printHeaderPortal(username);
                Console.WriteLine(" |1. Choose Location");
                Console.WriteLine(" |2. My complete order history");
                Console.WriteLine(" |3. sign out");
                Console.WriteLine(" |________________________________________________________________");

                signedInChoice = IntCheck.IntChecker();
                if (signedInChoice == -1)
                {
                    continue;
                }

                //This choice signifies selecting the pizza parlor you wish to engage with
                if (signedInChoice == 1)
                {
                    //CSL.choosePizzaStoreLocation(username, stores, orderHistory);
                    Console.WriteLine("Working on it");
                    _c_ChooseStoreLocation.choosePizzaStoreLocation(username, repo, orderRepo, pizzaRepo, storeRepo);
                }
                // Show all order history
                else if (signedInChoice == 2)
                {
                    Ordering.OrderHistory.DisplayOrderHistory(username, repo, pizzaRepo, orderRepo);
                }
                // Sign out
                else if (signedInChoice == 3)
                {
                    Console.WriteLine("Signing Out...");
                    Thread.Sleep(500);
                }
            }
        }
        /// <summary>
        /// Call this method to print all Cx Pizza's in their current order
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="currentOrder"></param>
        public static int printCxPrevOrdersAtCurrLoc(string username, string storeName, CurrentOrder curOrd)
        {
            Console.Clear();
            ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);

            // At each order location write all the pizza sizes, crust and price's in each order
            Console.WriteLine(" | user: <{0}> order totalled: <${1}> |", curOrd.userName, curOrd.currOrderTotal);
            Console.WriteLine(" |----------------------------------------");
            // At each order give brief description of the pizza's ordered
            int pizzaLineCounter = 1;

            foreach (Pizza pOrd in curOrd.pizzasInOrder)
            {
                // give toppings
                Console.Write(" |{0}: {1} {2} pizza with", pizzaLineCounter, pOrd.pizzaSize, pOrd.getCrustChoice());
                List <string> tops = pOrd.getChosenToppings();
                foreach (string pTop in tops)
                {
                    Console.Write(" <{0}>", pTop);
                }
                Console.WriteLine();
                Console.WriteLine(" | ---- Pizza Cost ---- <{0}>", pOrd.getPriceOfPizza());
                Console.WriteLine(" |");
                pizzaLineCounter++;
            }
            Console.WriteLine(" |_________________________________________________________\n");
            Console.WriteLine("1.<accept>  2.<deny>");

            int res = -1;

            while (res < 1 || res > 2)
            {
                res = IntCheck.IntChecker();
                if (res == -1)
                {
                    continue;
                }
            }
            return(res);
        }
        /// <summary>
        /// Choose Pizza Location
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        public static void choosePizzaStoreLocation(string username,
                                                    Abstractions.IRepositoryCustomer <Customer1> repo,
                                                    Abstractions.IRepositoryOrders <Order1> orderRepo,
                                                    Abstractions.IRepositoryPizza <Pizza1> pizzaRepo,
                                                    Abstractions.IRepositoryStore <Store1> storeRepo)
        {
            var customer = repo.ReadInCustomer();
            var order    = orderRepo.ReadInOrder();
            var pizza    = pizzaRepo.ReadInPizza();
            var store    = storeRepo.ReadInStore();

            int locationChoice = -1;

            while (locationChoice != 0)
            {
                Console.Clear();
                Console.WriteLine(" __________________________________________________________");
                Console.WriteLine(" | Hello:\t[" + username + "]");
                Console.WriteLine(" |---------------------------------------------------------");
                Console.WriteLine(" | Select a Pizza Parlor Location");
                Console.WriteLine(" |_________________________________________________________");

                // read through the list of Pizza parlors available.
                Dictionary <int, int> LocChoice = new Dictionary <int, int>();
                int storeCount = 0;
                foreach (var s in store)
                {
                    //DateTimeLogic.MostRecentOrder.getMostRecentOrder(store, customer, order, username);
                    // var cx = customer.OrderByDescending(Cx => Cx.Fname != null && Cx.Fname.Equals(username));
                    var Cus = customer.FirstOrDefault(Cx => Cx.Fname.Equals(username));

                    DateTime dt    = DateTime.Now;
                    double   time  = 25;
                    double   date2 = 25;
                    // For each order go through and check if store id and customer id match
                    foreach (var Ord in order)
                    {
                        if (Cus.Id == Ord.CustId && Ord.StoreId == s.Id)
                        {
                            TimeSpan ts2 = (TimeSpan)(dt - Ord.OrderDate);
                            date2 = ts2.TotalMinutes / 60;
                            if (date2 < time)
                            {
                                time = date2;
                            }
                        }
                    }

                    if (time >= 24)
                    {
                        //Console.WriteLine($"Yes visited and time {time}hrs ago");
                        storeCount++;
                        Console.WriteLine($" |{storeCount}. :  {s.StoreName}");
                        Console.WriteLine($" |        {s.StoreLocation}");
                        Console.WriteLine(" |");
                        LocChoice.Add(storeCount, s.Id);
                    }
                    else
                    {
                        Console.WriteLine($" | Plese wait 24 hours before ordering from \"{s.StoreName}\" again.");
                        Console.WriteLine($" | \t - You have {Math.Round((24 - time), 2)} hours remaining.");
                        Console.WriteLine(" |");
                    }
                }
                Console.WriteLine(" |0. : Return to previous page.");
                Console.WriteLine(" |_________________________________________________________");

                locationChoice = IntCheck.IntChecker();
                if (locationChoice == -1)
                {
                    continue;
                }

                // choose location and bring up data about that location
                if (locationChoice > 0 && locationChoice <= storeCount)
                {
                    var Loc = store.FirstOrDefault(S => S.Id == LocChoice[locationChoice]);

                    // Call Main logic for In Store.
                    _d_StorePortal.inStoreLogic(username, Loc.StoreName, repo, orderRepo, pizzaRepo, storeRepo);
                }

                if (locationChoice == 0)
                {
                    Console.WriteLine("returning to the previous page...");
                    Thread.Sleep(500);
                    break;
                }
            }
        }
Example #6
0
        /// <summary>
        /// The main logic for Ordering a pizza type
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="CurOrd"></param>
        // public void pizzaMakerChoice(string username, StoreRepository stores, int locationChoice, CurrentOrder CurOrd, OrderHistory LocationOrderHistory)
        public static void pizzaMakerChoice(string username, string storeName, CurrentOrder CurOrd)
        {
            int presetPizzaOptional = -1;

            while (presetPizzaOptional != 0)
            {
                ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                Console.WriteLine(" |  :: Choose Pizza Type ::");
                Console.WriteLine(" | 1. : Hawaiian");
                Console.WriteLine(" | 2. : Meat Lovers");
                Console.WriteLine(" | 3. : Pepperoni");
                Console.WriteLine(" | 4. : [MAKE YOUR OWN]");
                Console.WriteLine(" | 0. : return to previous page...");
                Console.WriteLine(" |_________________________________________________________");

                presetPizzaOptional = IntCheck.IntChecker();
                if (presetPizzaOptional == -1)
                {
                    continue;
                }

                if (presetPizzaOptional == 4)
                {
                    ZZ_PizzaSizes.printPizzaSizeChoice(username, storeName, "Custom Pizza");
                    Pizza CustomPizza = new Pizza(); // Comes with sauce and Cheese
                    _f_PizzaSizeChoice.presetPizzaSizeChoice(username, storeName, CustomPizza, CurOrd, true);
                }

                // Customer chose Hawaiian preset pizza.
                else if (presetPizzaOptional == 1)
                {
                    ZZ_PizzaSizes.printPizzaSizeChoice(username, storeName, "Hawaiian Pizza");
                    Pizza HawaiiPizza = new Pizza(); // Comes with sauce and Cheese
                    HawaiiPizza.setDefaultToppings();
                    HawaiiPizza.addToppings(Pizza.Toppings.pineapple);
                    HawaiiPizza.chooseCrust(Pizza.Crust.deepdish);
                    _f_PizzaSizeChoice.presetPizzaSizeChoice(username, storeName, HawaiiPizza, CurOrd, false);
                }
                // Cx chose Meat Lovers
                else if (presetPizzaOptional == 2)
                {
                    ZZ_PizzaSizes.printPizzaSizeChoice(username, storeName, "Meat Lovers");
                    Pizza MeatLovers = new Pizza(); // Comes with sauce and Cheese
                    MeatLovers.setDefaultToppings();
                    MeatLovers.addToppings(Pizza.Toppings.pepperoni);
                    MeatLovers.addToppings(Pizza.Toppings.sausage);
                    MeatLovers.chooseCrust(Pizza.Crust.deepdish);
                    _f_PizzaSizeChoice.presetPizzaSizeChoice(username, storeName, MeatLovers, CurOrd, false);
                }
                // Cx chose Pepperoni
                else if (presetPizzaOptional == 3)
                {
                    ZZ_PizzaSizes.printPizzaSizeChoice(username, storeName, "Pepperoni");
                    Pizza Pepperoni = new Pizza(); // Comes with sauce and Cheese
                    Pepperoni.setDefaultToppings();
                    Pepperoni.addToppings(Pizza.Toppings.pepperoni);
                    Pepperoni.chooseCrust(Pizza.Crust.deepdish);
                    _f_PizzaSizeChoice.presetPizzaSizeChoice(username, storeName, Pepperoni, CurOrd, false);
                }
            }
        }
        /// <summary>
        /// Main Logic for initial choices a Cx can make when they login to the store
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="CurOrd"></param>
        /// <param name="LocationOrderHistory"></param>

        public static void inStoreLogic(string username, string storeName,
                                        Abstractions.IRepositoryCustomer <Customer1> repo,
                                        Abstractions.IRepositoryOrders <Order1> orderRepo,
                                        Abstractions.IRepositoryPizza <Pizza1> pizzaRepo,
                                        Abstractions.IRepositoryStore <Store1> storeRepo)
        {
            var customer = repo.ReadInCustomer();
            var order    = orderRepo.ReadInOrder();
            var pizza    = pizzaRepo.ReadInPizza();
            var store    = storeRepo.ReadInStore();

            // Create new order object to temporarily store the order before confirming it.
            CurrentOrder curOrder      = new CurrentOrder();
            int          inStoreChoice = -1;

            while (inStoreChoice != 0)
            {
                ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                Console.WriteLine(" |---------------------------------------------------------");
                Console.WriteLine(" | 1. : Order a Pizza.");
                Console.WriteLine(" | 2. : Preview Your Current Order.");
                Console.WriteLine(" | 3. : [ADMIN] Preview All Orders at this Location.");
                Console.WriteLine(" | 0. : Return to Restaurant choice.");
                Console.WriteLine(" |_________________________________________________________");

                inStoreChoice = IntCheck.IntChecker();
                if (inStoreChoice == -1)
                {
                    continue;
                }

                // Pizza Size
                if (inStoreChoice == 1)
                {
                    _e_PizzaMakeChoice.pizzaMakerChoice(username, storeName, curOrder);
                }

                if (inStoreChoice == 2)
                {
                    if (curOrder.pizzasInOrder.Count == 0)
                    {
                        Console.Clear();
                        Console.WriteLine("No pizza's ordered yet!");
                        Thread.Sleep(500);
                    }
                    else
                    {
                        inStoreChoice = 0; // trying to for customer back to store choice after checking out a pizza.
                        // Ordering.CxCurrentOrder.getCustCurrentOrder(username, storeName, curOrder, customer);
                        int num = CxOrdersAtLocation.printCxPrevOrdersAtCurrLoc(username, storeName, curOrder);

                        if (num == 1) // try to read int choice
                        {
                            // Randomize and create new order.
                            Random random  = new Random();
                            int    OrderID = random.Next(1000000000, 2000000000);
                            var    cx      = customer.FirstOrDefault(Cx => Cx.Fname != null && Cx.Fname.Equals(username));
                            var    stor    = store.FirstOrDefault(S => S.StoreName.Equals(storeName));

                            // Tally the complete order first to get the total.
                            double total = 0;
                            foreach (var pi in curOrder.pizzasInOrder)
                            {
                                total += pi.getPriceOfPizza();
                            }

                            // Create new order and submit.
                            Order1 Or = new Order1()
                            {
                                CustId  = cx.Id,
                                OrderId = OrderID,
                                StoreId = stor.Id,
                                Price   = (decimal)total
                            };
                            orderRepo.CreateOrder(Or);

                            foreach (var pie in curOrder.pizzasInOrder)
                            {
                                //
                                char [] tops = Ordering.AddToppingsToPie.getAddToppingsToPie(pie);

                                // Convert toppings int a singular decimal representing a bit flag
                                int    topSet = BitFlagConversion.convertFlagArrayToInt(tops);
                                Pizza1 Cu     = new Pizza1()
                                {
                                    PizzaId  = random.Next(1000000000, 2000000000),
                                    Toppings = topSet,
                                    Crust    = pie.getCrustChoice(),
                                    Size     = pie.getSizeChoice(),
                                    OrderId  = OrderID,
                                    Price    = (decimal)pie.getPriceOfPizza()
                                };

                                pizzaRepo.CreatePizza(Cu);
                            }
                        }
                    }
                }
                // Look at previous order history at current location
                if (inStoreChoice == 3)
                {
                    Ordering.RestaurantOrdersEmployee.AllRestaurantOrders(orderRepo, storeRepo, username, storeName);
                }

                if (inStoreChoice == 0)
                {
                    Console.WriteLine("returning to the previous page...");
                    Thread.Sleep(700);
                    break;
                }
            }
        }
        /// <summary>
        /// Add a preset Pizza of specified type
        /// </summary>
        /// <param name="username"></param>
        /// <param name="stores"></param>
        /// <param name="locationChoice"></param>
        /// <param name="PresetPizza"></param>
        /// <param name="CurOrd"></param>
        public static void presetPizzaSizeChoice(string username, string storeName, Pizza PresetPizza, CurrentOrder CurOrd, bool custom)
        {
            // Get price of pizza
            int sizeOfPizza = -1;

            while (sizeOfPizza != 0)
            {
                if (!int.TryParse(Console.ReadLine(), out sizeOfPizza)) // try to read int choice
                {
                    Console.WriteLine("Not an option");
                    sizeOfPizza = -1;
                    continue;
                }
                if (sizeOfPizza == 1)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.twelveInch;
                }
                else if (sizeOfPizza == 2)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.fifteenInch;
                }
                else if (sizeOfPizza == 3)
                {
                    PresetPizza.pizzaSize = Pizza.PizzaSize.twentyInch;
                }
                else
                {
                    sizeOfPizza = -1;
                    continue;
                }
                if (custom)
                {
                    // This is the crust option
                    ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                    {
                        int crustCheck = -1;
                        while (crustCheck < 1 || crustCheck > 3)
                        {
                            Console.WriteLine(" | Pizza Crust Selection.");
                            Console.WriteLine(" |---------------------------------------------------");
                            Console.WriteLine(" | 1. thin");
                            Console.WriteLine(" | 2. deep dish");
                            Console.WriteLine(" | 3. cheese filled");
                            Console.WriteLine(" |___________________________________________________");

                            int crustChoice = IntCheck.IntChecker();
                            if (crustChoice == -1)
                            {
                                continue;
                            }

                            if (crustChoice == 1)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.thin);
                                crustCheck = 1;
                            }
                            else if (crustChoice == 2)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.deepdish);
                                crustCheck = 1;
                            }
                            else if (crustChoice == 3)
                            {
                                PresetPizza.chooseCrust(Pizza.Crust.cheesefilled);
                                crustCheck = 1;
                            }
                            else
                            {
                                Console.WriteLine("Not an option");
                                Thread.Sleep(1100);
                            }
                        }
                    }
                    // This is the toppings choice.
                    List <string> toppings = new List <string>();
                    List <string> fullTops = new List <string>();

                    fullTops.Add("sauce");
                    fullTops.Add("cheese");
                    fullTops.Add("pepperoni");
                    fullTops.Add("sausage");
                    fullTops.Add("pineapple");

                    for (int i = 0; i < 5; i++)
                    {
                        ZZ_PrintLoggedInHeader.printStoreHeaderLoggedIn(username, storeName);
                        if (toppings.Count == 0)
                        {
                            Console.WriteLine(" | You may choose up to five toppings.. Hit enter after each submission.");
                            Console.WriteLine(" |---------------------------------------------------");
                        }
                        else
                        {
                            Console.Write(" | ");
                        }
                        foreach (var top in toppings)
                        {
                            Console.Write($" <{top}>");
                        }
                        if (toppings.Count > 0)
                        {
                            Console.WriteLine();
                        }
                        int count = 0;
                        foreach (var fTop in fullTops)
                        {
                            Console.WriteLine($" | {count+1}. {fTop}");
                            count++;
                        }

                        Console.WriteLine(" | 0. [COMPLETED TOPPING CHOICE]...");
                        Console.WriteLine(" |______________________________________________________");

                        int toppingChoice = IntCheck.IntChecker();
                        if (toppingChoice == -1 || toppingChoice > fullTops.Count)
                        {
                            i--;
                            continue;
                        }
                        if (toppingChoice == 0)
                        {
                            break;
                        }

                        // remove from remaining toppings for customer
                        string temp = fullTops[toppingChoice - 1];
                        fullTops.RemoveAt(toppingChoice - 1);
                        toppings.Add(temp);
                    }
                    foreach (var tops in toppings)
                    {
                        if (tops.Equals("sauce"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.sauce);
                        }
                        else if (tops.Equals("cheese"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.cheese);
                        }
                        else if (tops.Equals("pepperoni"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.pepperoni);
                        }
                        else if (tops.Equals("sausage"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.sausage);
                        }
                        else if (tops.Equals("pineapple"))
                        {
                            PresetPizza.addToppings(Pizza.Toppings.pineapple);
                        }
                    }
                }

                // if user chooses to confirm then add order.
                if (_g_PizzaConfirmationToOrder.PizzaConfirmToOrder(username, storeName, PresetPizza))
                {
                    double check = 0;
                    foreach (var priceCheck in CurOrd.pizzasInOrder)
                    {
                        check += priceCheck.getPriceOfPizza();
                    }
                    if ((check + PresetPizza.getPriceOfPizza()) > 250)
                    {
                        Console.WriteLine("This pizza will push your maximum order limit.\n " +
                                          "Please check out at your earliest convenience. " +
                                          "<Press any key> to return to the previous page..");
                        Console.ReadLine();
                        break;
                    }
                    // Add The pizza to the order for this restaurant and user
                    CurOrd.confirmPizzaOrder(PresetPizza, username, storeName);
                    sizeOfPizza = 0;
                }
                else
                {
                    sizeOfPizza = 0;
                }
            }
        }