Ejemplo n.º 1
0
        /// <summary>
        /// Choose menu "Change password"
        /// </summary>
        public static void ChangePassword()
        {
            string inputPassword;

            Print.PrintHeader("Change password", ConsoleColor.DarkYellow);
            inputPassword = Print.ReadInput("Enter new password (at least 3 characters):");

            if (!ParseInput.IsCorrectPassword(inputPassword))
            {
                return;
            }

            if (!StartActions.UserLogic.ChangePassword(inputPassword))
            {
                Console.WriteLine("Password  hasn't changed!");
            }
            else
            {
                Console.WriteLine("Password  has changed!");
            }
        }
        /// <summary>
        /// Choose menu 'Register'
        /// </summary>
        public static void Register()
        {
            GuestLogic = new GuestLogic();
            string name, email, password, input;

            while (true)
            {
                Console.Clear();
                Print.PrintHeader("REGISTER", ConsoleColor.DarkYellow);

                name = Print.ReadInput("\nEnter your name (at least 3 characters): ");
                if (!ParseInput.IsCorrectName(name))
                {
                    Console.WriteLine("\nIncorrect name!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }

                email = Print.ReadInput("\nEnter user email (*****@***): ");
                if (!ParseInput.IsCorrectEmail(email))
                {
                    Console.WriteLine("\nIncorrect email!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }

                password = Print.ReadInput("\nEnter password (at least 3 characters): ");
                if (!ParseInput.IsCorrectPassword(password))
                {
                    Console.WriteLine("\nIncorrect password!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                    else
                    {
                        continue;
                    }
                }
                if (!GuestLogic.Register(name, email, password))
                {
                    Console.WriteLine("\nUser with this email already exists!");
                    input = Print.ReadInput("\n[1] Try again\nor enter any other key to return");
                    if (input != "1")
                    {
                        return;
                    }
                }
                else
                {
                    break;
                }
            }

            GuestLogic.LogIn(email, password);

            Console.Clear();
            if (UserLogic.GetAccountType().Equals("USER"))
            {
                UserActions.UserMode();
            }
            else
            {
                UserActions.AdminMode();
            }

            while (true)
            {
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);

                UserActions.GetActions();

                input = Console.ReadLine();
                Console.Clear();
                Print.PrintHeader($"{UserLogic.GetAccountType()}: {UserLogic.GetAccountName()}", ConsoleColor.Green);
                if (input.ToLower() == "q")
                {
                    UserLogic.LogOut();
                    break;
                }

                UserActions.ChooseAction(input);
            }
        }