public static bool LoggedInStatus = false;  //Check Logged in status

        public void SelectActionToPerform()         //Home Page Options
        {
            TrainManager trainManager = new TrainManager();
            UserManager  userManager  = new UserManager();

            int choice;

            Console.WriteLine("*************Welcome to Online Train Ticket Booking System ******************");

            while (startUp)
            {
                Console.WriteLine("\n[Choose an option]\n1)Search for Train\n2)New User? SignUp\n3)Login\n4)Log Out\n5)Exit");
                choice = Validate.ValidateInteger(Console.ReadLine());
                switch (choice)
                {
                case 1: trainManager.SearchTrain();
                    break;

                case 2: userManager.RegisterUser();
                    break;

                case 3:
                    if (!LoggedInStatus)
                    {
                        userManager.Login();
                    }
                    else
                    {
                        Console.WriteLine("[WARN]    You must Log Out to Login ");
                    }
                    break;

                case 4:
                    if (LoggedInStatus)
                    {
                        startUp = false;
                    }
                    else
                    {
                        Console.WriteLine("[WARN]    You must Login to Log Out");
                    }
                    break;

                case 5:
                    return;

                default:
                    Console.WriteLine("Select a valid choice");
                    break;
                }
            }
        }
Exemple #2
0
        public static void UserBookingOptions() //Provides User Option
        {
            TrainManager trainManager = new TrainManager();

            while (HomePage.LoggedInStatus)
            {
                Console.WriteLine("\n[Select a option]\n1)Book Ticket\n2)Search Train Availability\n3)Display Booking Detail\n4)Cancel Booking\n5)Exit");
                int choice = Validate.ValidateInteger(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    if (HomePage.LoggedInStatus)
                    {
                        trainManager.BookTicket();
                    }
                    else
                    {
                        Console.WriteLine("You Must Login to Book the Ticket");
                        HomePage.startUp = true;
                    }
                    break;

                case 2:
                    trainManager.SearchTrain();
                    break;

                case 3:
                    PassengerRepository.DisplayBookingDetail();
                    break;

                case 4:
                    PassengerRepository.CancelBooking();
                    break;

                case 5:
                    HomePage.LoggedInStatus = false;
                    break;

                case 6:
                    Console.WriteLine("[WARN]  --Select a valid choice");
                    break;
                }
            }
        }