Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // ValidationSevice validationSevice = new ValidationSevice();
            var validationSevice = new ValidationSevice();

            string email = Console.ReadLine();

            if (!validationSevice.ValidateEmail(email))
            {
                Console.WriteLine("Enter valid email.");
            }
            else
            {
                Console.WriteLine("Great it works");
            }

            string password = Console.ReadLine();

            if (!validationSevice.ValidatePassword(password))
            {
                Console.WriteLine("Password is not valid, should be minimum 8 chars 1 upper letter and 1 digit");
            }
            else
            {
                Console.WriteLine("Super it works");
            }

            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Generate default users
            User[] users = GenerateUsers();
            // ValidationSevice validationSevice = new ValidationSevice();
            var validationSevice = new ValidationSevice();

            while (true)
            {
                Console.WriteLine("\nRegistration press 1 \nLogin press 2 \nExit press 3");
                string userSelection = Console.ReadLine();
                if (!int.TryParse(userSelection, out int validUserSelection))
                {
                    Console.WriteLine("Not valid input. Please try again.");
                    continue;
                }

                switch (validUserSelection)
                {
                case 1:
                    User newUser = Authentication.Register(users, validationSevice);
                    Array.Resize(ref users, users.Length + 1);
                    users[users.Length - 1] = newUser;
                    Console.Clear();
                    Console.WriteLine($"Thank you for registering {newUser.GetFullName()} \n");
                    PrintUsers(users);
                    break;

                case 2:
                    User user = Authentication.Login(users, validationSevice);
                    if (user == null)
                    {
                        break;
                    }
                    Console.Clear();
                    Console.WriteLine($"Welcome {user.GetFullName()} \n");
                    PrintUsers(users);
                    break;

                case 3:
                    Console.WriteLine("Thank you for using our application");
                    Console.ReadLine();
                    return;

                default:
                    Console.WriteLine("Wrong input");
                    Console.ReadLine();
                    return;
                }
            }
        }