Ejemplo n.º 1
0
        public static void userMenu()
        {
            bool loopBreak = false;

            do
            {
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("Press X to Log out | Press P to change your password");
                string userAction = Console.ReadLine().ToUpper(); //User's choice

                string choice = userOptions.ElementAt(userChoice(userAction));

                if (choice == "!")
                {
                    Console.WriteLine("Unknown Input Detected | Try again"); //if unrecognised input, ask user to try again
                }
                else if (choice == "X")
                {
                    System.Environment.Exit(1); //Exit the software
                }
                else if (choice == "P")         //Reset user's password
                {
                    Console.WriteLine("Please enter your current password");
                    string oldPassword = Console.ReadLine();
                    UserLogins.changePassword(oldPassword); //passes current password input to method to update password
                }
            } while (loopBreak == false);
        }
Ejemplo n.º 2
0
 public static void adminAuthourisation(List <string> loginCheck)
 {
     if (UserLogins.authorisedCheck(loginCheck) == true) //If admin login is recognised
     {
         Console.WriteLine("Admin Override Successful");
         Console.WriteLine("Press Enter to Close the Software");
         Console.ReadLine();
         System.Environment.Exit(1); //Exit the software
     }
     else
     {
         Console.WriteLine("Unrecognised Admin Login | Try Again" + Environment.NewLine); //Ask user to re-enter admin Login
     }
 }
Ejemplo n.º 3
0
        public static void adminMenu()
        {
            bool loopBreak = false;

            do
            {
                Console.WriteLine(""); //Displays list of options for Admin
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("Press V to view user details | Press A to add users to the system |");
                Console.WriteLine("Press R to remove a user from the system | Press X to exit the system|");
                string userChoice = Console.ReadLine().ToUpper();                //saves choice

                string choice = adminOptions.ElementAt(adminChoice(userChoice)); //passes choice to method to check against possible answers

                if (choice == "!")
                {
                    Console.WriteLine("Unknown Input Detected | Try again"); //Asks user to re-enter choice
                }
                else if (choice == "V")
                {
                    UserLogins.userOutput(); //View all User information
                }
                else if (choice == "A")
                {
                    UserLogins.addUsers(); //Add a new user to the system
                }
                else if (choice == "R")
                {
                    UserLogins.removeUsers(); //Remove a user from the system
                }
                else if (choice == "X")
                {
                    System.Environment.Exit(1); //Closes the software
                }
            } while (loopBreak == false);
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            bool   loopBreak     = false;
            bool   adminOverride = false;
            string check         = "";
            string loginError;

            Console.WriteLine("Welcome to the Company System"); //Welcomes the user

            do
            {
                Console.WriteLine("Please Enter your Username");
                string usernameInput = Console.ReadLine().ToUpper(); //stores user input of username

                Console.WriteLine("Please Enter your Password");
                string passwordInput = Console.ReadLine(); //stores user input of password

                List <string> loginInput = new List <string>(2)
                {
                    usernameInput, passwordInput                       //stores inputted login in list
                };
                bool loginMatch = UserLogins.detailsCheck(loginInput); //passes login info to method for validation

                bool          adminCheck  = false;
                List <string> userDetails = new List <string>(2);


                if (loginMatch == true)                                 //if login successful
                {
                    userDetails = UserLogins.retrieveName(userDetails); //retrives user's name for welcome message from method

                    adminCheck = UserLogins.checkAdmin(check);          //retrieves user's admin status from method
                }


                if (loginMatch == true & adminCheck == true) //if user is logged in and an admin
                {
                    loopBreak = true;
                    Console.WriteLine("Welcome Admin: {0} {1}", userDetails.ElementAt(0), userDetails.ElementAt(1)); //personalised welcome message
                    AdminUser.adminMenu();                                                                           //Loads Admin menu
                }
                else if (loginMatch == true)                                                                         //if user is logged in but not an admin
                {
                    Console.WriteLine("Welcome {0} {1}", userDetails.ElementAt(0), userDetails.ElementAt(1));        //personalised welcome message
                    User.userMenu();                                                                                 //LOads Regular User Menu
                    loopBreak = true;
                }
                else if (UserLogins.loginAttempts == 0)           //If user has not logged in and has used all login attempts
                {
                    loginError = UserLogins.attemptsCheck(check); //calls error to display
                    Console.WriteLine("");
                    Console.WriteLine(loginError + Environment.NewLine);
                    loopBreak     = true;
                    adminOverride = true;
                }
                else
                {
                    loginError = UserLogins.attemptsCheck(check); //if user has not logged in and has login attempts remaining
                    Console.WriteLine(loginError);                //displays error
                    Console.WriteLine("");
                    loopBreak = false;
                }
            } while(loopBreak == false);

            do //admin override
            {
                Console.WriteLine("Enter Admin Username");
                string adminUsername = Console.ReadLine().ToUpper(); //entered Admin Login
                Console.WriteLine("Enter Admin Password");
                string adminPassword = Console.ReadLine();           //entered Admin Password

                List <string> adminInput = new List <string>(2)
                {
                    adminUsername, adminPassword //stores entered login as list
                };

                AdminOverride.adminAuthourisation(adminInput); //checks login list against recognised Admin logins
            } while (adminOverride == true);

            Console.ReadLine();
        }