private void AsGuestOption()
        {
            UserMenu userMenu = new UserMenu(mainBoard, null);

            while (!userMenu.isExitSelected)
            {
                userMenu.GetUserOption();
            }
        }
        private void SignUpOption()
        {
            // Getting input:
            DateTime bdate;

            Console.WriteLine("\nEnter your information:\nEmail:");
            var email = Console.ReadLine();

            Console.WriteLine("First name:");
            var fname = Console.ReadLine();

            Console.WriteLine("Last name");
            var lname = Console.ReadLine();

            try
            {
                Console.WriteLine("Birth year:");
                var year = Int32.Parse(Console.ReadLine());

                Console.WriteLine("Birth month:");
                var month = Int32.Parse(Console.ReadLine());

                Console.WriteLine("Birth day:");
                var day = Int32.Parse(Console.ReadLine());

                bdate = new DateTime(year, month, day);
            }
            catch (FormatException excep)
            {
                Console.WriteLine(excep);
                return;
            }

            // Adding it to DB:
            var newUser = new User(email, fname, lname, bdate);

            if (mainBoard.AddUser(newUser))
            {
                _loggedUser = newUser;

                // Implementing a new User Menu & running it:
                var userMenu = new UserMenu(mainBoard, _loggedUser);
                while (!userMenu.isExitSelected)
                {
                    userMenu.GetUserOption();
                }
            }
            else
            {
                Console.WriteLine("User already exists!");
                return;
            }
        }
예제 #3
0
        private void SignUpOption()
        {
            string   email, fname, lname;
            int      year, month, day;
            DateTime bdate;

            Console.WriteLine("\nEnter your information:\nEmail:");
            email = Console.ReadLine();

            Console.WriteLine("First name:");
            fname = Console.ReadLine();

            Console.WriteLine("Last name");
            lname = Console.ReadLine();

            try
            {
                Console.WriteLine("Birth year:");
                year = Int32.Parse(Console.ReadLine());

                Console.WriteLine("Birth month:");
                month = Int32.Parse(Console.ReadLine());

                Console.WriteLine("Birth day:");
                day = Int32.Parse(Console.ReadLine());

                bdate = new DateTime(year, month, day);
            }
            catch (FormatException excep)
            {
                Console.WriteLine(excep);
                return;
            }

            User newUser = new User(email, fname, lname, bdate);

            mainBoard.AddUser(newUser);
            loggedUser = newUser;

            // Implementing a new User Menu;
            UserMenu userMenu = new UserMenu(mainBoard, loggedUser);

            while (!userMenu.isExitSelected)
            {
                userMenu.GetUserOption();
            }
        }
        /*
         * Switch case options:
         */
        private void LoginOption()
        {
            Console.WriteLine("Enter your email:");
            var email = Console.ReadLine();

            // Looking for user in DB:
            var foundUser = mainBoard.FindUser(email);

            if (foundUser != null)
            {
                _loggedUser = foundUser;

                //Initializing a new user menu instance:
                var userMenu = new UserMenu(mainBoard, _loggedUser);

                //Running UserMenu:
                while (!userMenu.isExitSelected)
                {
                    userMenu.GetUserOption();
                }
            }
        }
예제 #5
0
        /*
         * Switch case options:
         */
        private void LoginOption()
        {
            Console.WriteLine("Enter your email:");
            string email;

            email = Console.ReadLine();

            User foundUser = mainBoard.FindUser(email);

            if (foundUser != null)
            {
                loggedUser = foundUser;
                UserMenu userMenu = new UserMenu(mainBoard, loggedUser);
                while (!userMenu.isExitSelected)
                {
                    userMenu.GetUserOption();
                }
            }
            else
            {
                loggedUser = null;
                Console.WriteLine("User not found!");
            }
        }