Ejemplo n.º 1
0
        public void checkBookingFlightStatus()
        {
            // Intitialise for later use.
            SubMenus subMenu = new SubMenus();

            JSON           json        = new JSON();
            List <Booking> bookingData = json.readBookingData();
            List <Flight>  flightData  = json.readFlightData();


            Console.Clear();

            bool intTestLoop = true;

            // Test input for booking ID is correct type.
            while (intTestLoop)
            {
                Console.Write("Please enter the booking reference no:");

                // If the input is an int.
                if (int.TryParse(Console.ReadLine(), out int bookingIDTest))
                {
                    // If booking ID does not exist in booking list (i.e. incorrect id entered).
                    if (!bookingData.Any(b => b.bookingID == bookingIDTest))
                    {
                        Console.Write("\nBooking ID is incorrect, please try again.\n\n");
                    }
                    else
                    {
                        intTestLoop = false;
                        bookingID   = bookingIDTest;
                    }
                }
                // If the input is NOT an int.
                else
                {
                    Console.Write("\nIncorrect input. Please try again.\n\n");
                }
            }

            // Cycle through the booking where the booking ID matches the one entered by the user.
            foreach (Booking b in bookingData.Where(b => b.bookingID == bookingID))
            {
                flightID      = b.flightID;
                customerName  = b.customerName;
                bookingStatus = b.bookingStatus;
            }

            foreach (Flight f in flightData.Where(f => f.flightID.ToLower() == flightID.ToLower()))
            {
                flightFrom     = f.flightFrom;
                flightTo       = f.flightTo;
                flightDateTime = f.flightDateTime;
            }

            // Temporary variable to hold result of converting bookingStatus to something meaningful to user.
            string status;

            // Convert bookingStatus into something meaningful to user.
            if (bookingStatus)
            {
                status = "Confirmed";
            }
            else
            {
                status = "Not Confirmed";
            }

            Console.Write("\n\nYour Booking Details" +
                          "\n========================================" +
                          "\nReference:\t{0}" +
                          "\nStatus:\t\t{1}" +
                          "\nName:\t\t{2}" +
                          "\nFlight No:\t{3}" +
                          "\nFlight From:\t{4}" +
                          "\nFlight To:\t{5}" +
                          "\nDate:\t\t{6:dd/MM/yyyy}" +
                          "\n\nPress any key to return to the menu.",
                          bookingID, status, customerName, flightID, flightFrom, flightTo, flightDateTime);

            Console.ReadKey();

            // Return to customer submenu.
            subMenu.customerSubMenu();
        }
Ejemplo n.º 2
0
        // Displays the main menu options.
        public void initMenu()
        {
            bool exitMenuLoop = false;

            while (!exitMenuLoop)
            {
                Console.Clear();

                Console.Write("Welcome to Around-The-World\n" +
                              "================================================\n" +
                              "\t1. Airline Employee\n\n" +
                              "\t2. Ticket Agent\n\n" +
                              "\t3. Customer\n\n" +
                              "\t4. Quit\n\n" +
                              "Enter an option:");

                string menuSelectString = Console.ReadLine();
                int    menuSelectInt;
                bool   menuSelectTest = int.TryParse(menuSelectString, out menuSelectInt);

                // If the input is an int
                if (menuSelectTest)
                {
                    // If the option selected is an int, between 1-4 (inclusive).
                    if (menuSelectInt > 0 & menuSelectInt < 5)
                    {
                        switch (menuSelectInt)
                        {
                        case 1:
                        {
                            // Display employee submenu.
                            exitMenuLoop = true;
                            SubMenus subMenu = new SubMenus();
                            subMenu.employeeSubMenu();
                            break;
                        }

                        case 2:
                        {
                            // Display flight centre (agent) submenu.
                            exitMenuLoop = true;
                            SubMenus subMenu = new SubMenus();
                            subMenu.agentSubMenu();
                            break;
                        }

                        case 3:
                        {
                            // Display customer submenu.
                            exitMenuLoop = true;
                            SubMenus subMenu = new SubMenus();
                            subMenu.customerSubMenu();
                            break;
                        }

                        case 4:
                        {
                            Environment.Exit(0);
                            break;
                        }
                        }
                    }
                    // If the option selected is an int, but NOT between 1-4 (inclusive).
                    else
                    {
                        Console.WriteLine("\nIncorrect input. The number has to be between 1 and 4." +
                                          "\nPress any key to try again.");
                        Console.ReadKey();
                    }
                }
                // If the option selected is NOT an int.
                else
                {
                    Console.Write("\nIncorrect input. Please enter a whole number between 1 and 4." +
                                  "\nPress any key to try again.");
                    Console.ReadKey();
                }
            }
        }