예제 #1
0
        static public User SignUp()
        {
            Console.Clear();
            string mail;
            string username;
            string password;
            string password1;
            int    stat;
            Random random = new Random();

            Console.WriteLine("Enter Username");
            username = Console.ReadLine();
            while (true)
            {
                Console.WriteLine("Enter eMail");
                mail = Console.ReadLine();
                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                if (regex.IsMatch(mail))
                {
                    break;
                }
            }
            while (true)
            {
                Console.WriteLine("1.Worker\n2.Employer");
                int.TryParse(Console.ReadLine(), out stat);
                if (stat == 1 || stat == 2)
                {
                    break;
                }
            }
            while (true)
            {
                Console.WriteLine("Enter Password");
                password = Console.ReadLine();
                Regex regex = new Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,15}$");
                if (regex.IsMatch(password))
                {
                    break;
                }
            }
            while (true)
            {
                Console.WriteLine("Confirm Password");
                password1 = Console.ReadLine();
                if (password == password1)
                {
                    break;
                }
            }
            while (true)
            {
                const string chars    = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz0123456789";
                string       chapctha = new string(Enumerable.Repeat(chars, 4).Select(s => s[random.Next(s.Length)]).ToArray());
                Console.WriteLine(chapctha + "\nEnter");
                string tmp = Console.ReadLine();
                if (chapctha == tmp)
                {
                    break;
                }
            }
            User user;

            if (stat == 1)
            {
                user = new Worker {
                    Username = username, Email = mail, Password = password, Stat = stat
                }
            }
            ;
            else
            {
                user = new Employer {
                    Username = username, Email = mail, Password = password, Stat = stat
                }
            };
            return(user);
        }
예제 #2
0
        public void EmployerMenu(Employer employer)
        {
            Console.Clear();
            int menu = 1;

            while (true)
            {
                int           i          = 0;
                List <string> workerMenu = new List <string>
                {
                    "Add advertisement",
                    "View Appeals",
                    "Log out"
                };
                foreach (var item in workerMenu)
                {
                    i++;
                    if (i == menu)
                    {
                        Console.BackgroundColor = ConsoleColor.White;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.WriteLine(item);
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = ConsoleColor.White;
                        continue;
                    }
                    Console.WriteLine(item);
                }
                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.UpArrow:
                    menu--;
                    if (menu == 0)
                    {
                        menu = 3;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    menu++;
                    if (menu == 4)
                    {
                        menu = 1;
                    }
                    break;

                case ConsoleKey.Enter:
                    if (menu == 1)
                    {
                        employer.AddAdvertisement();
                    }
                    else if (menu == 2)
                    {
                        employer.ViewAppeals();
                    }
                    else if (menu == 3)
                    {
                        return;
                    }
                    break;
                }
                Console.Clear();
            }
        }