Example #1
0
        public void EnterSelections()
        {
            DisplayItems();
            Console.WriteLine("Please enter the product code or [1] return to main menu.");
            string userInput = Console.ReadLine().ToUpper();

            if (userInput == "1")
            {
                MainMenu();
            }
            else if (vm.DidUserEnterValidProductCode(userInput) && vm.RemoveItem(userInput))
            {
                productCodes.Add(userInput);
                Console.Clear();
            }
            else if (!vm.RemoveItem(userInput))
            {
                Console.WriteLine("Item is out of stock. Please press return and make a different selection.");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("You've entered an invalid product code. Please press return and try again.");
                Console.ReadLine();
                EnterSelections();
            }
            while (true)
            {
                DisplayItems();
                Console.WriteLine("You've currently selected: " + DisplayCurrentSelections());
                Console.WriteLine("Enter another product code, or: \n[C] to confirm selection(s) \n[1] to cancel current selections and return to the main menu.");
                userInput = Console.ReadLine().ToUpper();
                if (userInput == "C" && productCodes.Count > 0)
                {
                    break;
                }
                else if (userInput == "C" && productCodes.Count == 0)
                {
                    Console.WriteLine("You must enter a product code before confirming your selection.");
                    EnterSelections(); //This still needs some work. Count is never truly 0. Im going to come back to this later.
                }
                else if (userInput == "1")
                {
                    ClearSelectionsPayments();
                    vm.AddItemsBack(productCodes);
                    MainMenu();
                }
                else if (vm.DidUserEnterValidProductCode(userInput) && vm.RemoveItem(userInput))
                {
                    productCodes.Add(userInput);
                    continue;
                }
                else if (!vm.DidUserEnterValidProductCode(userInput))
                {
                    Console.WriteLine("You've entered an invalid product code. Please press return and try again.");
                    Console.ReadLine();
                    continue;
                }
                else if (!vm.RemoveItem(userInput))
                {
                    Console.WriteLine("Item is out of stock. Please press return and make a different selection.");
                    Console.ReadLine();
                    continue;
                }
            }
            Console.Clear();
            amountDue = vm.GetAmountDue().ToString("C");
            DisplayAmountDueAndAmountPaid();
            FeedMoney();
        }