Пример #1
0
        public static bool ValidatePassword(List <Person> members, string password)
        {
            foreach (Person member in members)
            {
                if (password == member.Password)
                {
                    Console.Clear();
                    Console.WriteLine("\nPassword already exists. Please try again.");
                    LoginMenu.PressAnyKey();

                    return(false);
                }
            }

            if (password.Length < 8)
            {
                Console.Clear();
                Console.WriteLine("\nPassword must be at least 8 characters long. Please try again");
                LoginMenu.PressAnyKey();


                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #2
0
        public static bool ValidateUsername(List <Person> members, string username)
        {
            foreach (Person member in members)
            {
                if (username == member.UserName)
                {
                    Console.Clear();
                    Console.WriteLine("\nUsername already exists. Please try again.");
                    LoginMenu.PressAnyKey();

                    return(false);
                }
            }

            if (username.Length < 4)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\nUsername must be at least 4 characters long. Please try again");
                Console.ResetColor();
                LoginMenu.PressAnyKey();


                return(false);
            }
            else
            {
                return(true);
            }
        }
        public static void DisplayChosenStudentInfo(List <Student> students)
        {
            Console.Clear();

            Console.WriteLine("\nEnter student's first name:");
            string studentFirstName = Console.ReadLine();

            Console.WriteLine("\nEnter student's last name:");
            string studentLastName = Console.ReadLine();

            Console.Clear();

            Student studentsInfoToDisplay = null;

            foreach (Student student in students)
            {
                if (studentFirstName == student.FirstName && studentLastName == student.LastName)
                {
                    studentsInfoToDisplay = student;
                    int i = 1;
                    Console.ForegroundColor = ConsoleColor.DarkCyan;

                    if (studentsInfoToDisplay.Grades.Count == 0)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkCyan;
                        Console.WriteLine("\nCurrently there is no info for this student's subjects.");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.WriteLine($"\nThese are all subjects of the student {student.FirstName} {student.LastName}\n");

                        foreach (var key in studentsInfoToDisplay.Grades.Keys)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            Console.Write($"{i}. ");
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write($"Subject: ");
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine($"{ key}\n");

                            i++;
                        }
                    }
                }
            }

            if (studentsInfoToDisplay == null)
            {
                Console.WriteLine("\nSorry no such student. Please make sure first name and last name are correct and match\n" +
                                  "If you want to try again, choose corresponding option from menu.");
            }

            Console.ResetColor();
            LoginMenu.PressAnyKey();
            Console.Clear();
        }
        public static void SubjectsInfo(List <Student> students)
        {
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("\nThese are all subjects of the academy\n");

            int subjectNum = 1;

            foreach (Subject subject in Enum.GetValues(typeof(Subject)))
            {
                if (subject == Subject.NoData)
                {
                    continue;
                }

                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    Console.Write($"{subjectNum}. ");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write($"Subject: ");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write($"{ subject}");
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    Console.Write(" | ");
                    Console.ForegroundColor = ConsoleColor.Cyan;

                    Console.Write("Number of attending students: ");

                    int subjectListenersCounter = 0;

                    // Logikava ovde e da pokaze za site predmeti kolku studenti gi slusale, nezavisno dali im se Current subject ili nekoi od vekje islusanite. Barem jas taka razbrav deka treba da se prikaze. Vo slucaj da treba da se prikazat samo slusatelite na predmet kojsto im e Current subject, bi stoel samo vtoriot if. I obratno, ako treba da se pokaze brojka na studenti samo za vekje islusanite predmeti, kje stoi samo prviot if.

                    foreach (Student student in students)
                    {
                        if (student.Grades.ContainsKey(subject))
                        {
                            subjectListenersCounter++;
                        }
                        if (student.CurrentSubject == subject)
                        {
                            subjectListenersCounter++;
                        }
                    }

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine($"{subjectListenersCounter}\n");
                    subjectNum++;
                }
            }

            Console.ResetColor();
            LoginMenu.PressAnyKey();
            Console.Clear();
        }
        public static void TrainerMenu(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"\nWould you like to:\n");
            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("[1] See all students of the Academy\n" +
                              "[2] See all subjects of the Academy\n" +
                              "[3] See all subjects of a particular student\n" +
                              "[4] Go back to login menu\n" +
                              "[5] Exit AcademyApp");

            Console.ForegroundColor = ConsoleColor.White;

            int chosenOption = int.Parse(Console.ReadLine());

            switch (chosenOption)
            {
            case 1:

                DisplayAllStudents(students);
                TrainerMenu(members, admins, trainers, students);
                break;

            case 2:
                SubjectsInfo(students);
                TrainerMenu(members, admins, trainers, students);

                break;

            case 3:
                DisplayChosenStudentInfo(students);
                TrainerMenu(members, admins, trainers, students);

                break;

            case 4:
                LoginMenu.MainMenuLogin(members, admins, trainers, students);
                break;

            case 5:
                Console.Clear();
                Console.WriteLine($"\nUntil next time trainer! Thank you for using AcademyApp.");
                LoginMenu.PressAnyKey();
                LoginMenu.MainMenuLogin(members, admins, trainers, students);

                break;

            default:
                Console.Clear();
                Console.WriteLine($"\nNo such option. Please try again.");
                LoginMenu.PressAnyKey();
                TrainerMenu(members, admins, trainers, students);
                break;
            }
        }
Пример #6
0
        public static void AdminMenu(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students, Person loggedInAdmin)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"\nWould you like to:\n");
            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("[1] Add an Academy member\n" +
                              "[2] Remove an Academy member\n" +
                              "[3] Go back to login menu\n" +
                              "[4] Exit AcademyApp");

            Console.ForegroundColor = ConsoleColor.White;

            int chosenOption = int.Parse(Console.ReadLine());

            switch (chosenOption)
            {
            case 1:
                AddAMember(members, admins, trainers, students, (Admin)loggedInAdmin);
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;

            case 2:
                RemoveAMember(members, admins, trainers, students, (Admin)loggedInAdmin);
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;

            case 3:
                LoginMenu.MainMenuLogin(members, admins, trainers, students);
                break;

            case 4:
                Console.Clear();
                Console.WriteLine($"\nUntil next time admin!");
                LoginMenu.PressAnyKey();
                LoginMenu.MainMenuLogin(members, admins, trainers, students);
                break;

            default:
                Console.Clear();
                Console.WriteLine($"\nNo such option. Please try again.");
                LoginMenu.PressAnyKey();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;
            }
        }
        public static void DisplayAllStudents(List <Student> students)
        {
            Console.Clear();

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine("\nThese are all the students of the academy:");
            for (int i = 0; i < students.Count; i++)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;

                Console.WriteLine($"\n{i + 1}. {students[i].FirstName} {students[i].LastName}");
            }

            Console.ResetColor();
            LoginMenu.PressAnyKey();
            Console.Clear();
        }
Пример #8
0
        public static void MainMenuLogin(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine($"\n=======================================================\n");
            Console.ResetColor();

            Console.WriteLine("Welcome to SEDC Academy :)\n");


            Console.WriteLine("Are you logging in as:\n" +
                              "[1] Admin\n" +
                              "[2] Trainer\n" +
                              "[3] Student\n");
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine($"\n=======================================================\n");
            Console.ResetColor();


            int userChoice = int.Parse(Console.ReadLine());

            switch (userChoice)
            {
            case 1:
                AdminServices.LoginAsAdmin(members, admins, trainers, students);
                break;

            case 2:
                TrainerServices.LoginAsTrainer(members, admins, trainers, students);
                break;

            case 3:
                StudentServices.LoginAsStudent(members);
                break;

            default:
                Console.Clear();
                Console.WriteLine("\nNo such choice. Please try again");
                LoginMenu.PressAnyKey();
                MainMenuLogin(members, admins, trainers, students);
                break;
            }
        }
Пример #9
0
        public static void LoginAsStudent(List <Person> members)
        {
            Person loggedInStudent = LoginMenu.LoginVerification(members);

            if (loggedInStudent == null)
            {
                Console.Clear();
                Console.WriteLine("\nSorry, no such student. Maybe you just misspelled your username and\\or password?\n" +
                                  "In any case, please try again.");

                LoginMenu.PressAnyKey();

                return;
            }

            loggedInStudent.PrintInfo();


            LoginMenu.PressAnyKey();
        }
Пример #10
0
        public static void LoginAsAdmin(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students)
        {
            Person loggedInAdmin = LoginMenu.LoginVerification(members);

            if (loggedInAdmin == null)
            {
                Console.Clear();

                Console.WriteLine("\nSorry, no such administrator. Maybe you just misspelled your username and\\or password?\n" +
                                  "In any case, please try again.");

                LoginMenu.PressAnyKey();

                return;
            }

            Console.Clear();
            Console.Write($"\nWelcome Admin ");
            loggedInAdmin.PrintInfo();
            AdminMenu(members, admins, trainers, students, loggedInAdmin);
        }
Пример #11
0
        public static bool ValidateLastName(string lastName)
        {
            try
            {
                while (lastName.Length < 2)
                {
                    Console.Clear();
                    Console.WriteLine("\nLast name must be at least 2 characters long.\n" +
                                      "\nPlease try again.");
                    LoginMenu.PressAnyKey();


                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.Clear();
                Console.WriteLine(ex.Message);
                LoginMenu.PressAnyKey();
            }
            return(true);
        }
Пример #12
0
        public static Tuple <List <Person>, List <Admin>, List <Trainer>, List <Student> > RemoveAMember(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students, Admin loggedInAdmin)
        {
            Console.Clear();

            Console.WriteLine("\nWould you like to remove:\n" +
                              "[1] An Admin\n" +
                              "[2] A Trainer\n" +
                              "[3] A Student");

            int adminChoice = int.Parse(Console.ReadLine());


            switch (adminChoice)
            {
            case 1:

                Person adminToRemove = LoginMenu.LoginVerification(members);

                if (adminToRemove == null)
                {
                    Console.Clear();
                    Console.WriteLine("\nSorry, no such admin. Please try again.");
                    LoginMenu.PressAnyKey();
                    Console.Clear();
                    break;
                }

                if (adminToRemove == loggedInAdmin)
                {
                    Console.Clear();
                    Console.WriteLine("\nCan't remove yourself");
                    LoginMenu.PressAnyKey();
                    Console.Clear();
                    break;
                }

                Console.Clear();
                Console.Write($"\nSuccessfully removed admin ");
                adminToRemove.PrintInfo();
                members.Remove(adminToRemove);
                admins.Remove((Admin)adminToRemove);
                LoginMenu.PressAnyKey();
                Console.Clear();
                break;

            case 2:

                Person trainerToRemove = LoginMenu.LoginVerification(members);

                if (trainerToRemove == null)
                {
                    Console.Clear();
                    Console.WriteLine("\nSorry, no such trainer. Please try again.");
                    LoginMenu.PressAnyKey();

                    break;
                }

                Console.Clear();
                Console.Write($"\nSuccessfully removed trainer ");
                trainerToRemove.PrintInfo();
                members.Remove(trainerToRemove);
                trainers.Remove((Trainer)trainerToRemove);
                LoginMenu.PressAnyKey();
                Console.Clear();
                break;

            case 3:

                Person studentToRemove = LoginMenu.LoginVerification(members);

                if (studentToRemove == null)
                {
                    Console.Clear();
                    Console.WriteLine("\nSorry, no such student. Please try again.");
                    LoginMenu.PressAnyKey();
                    break;
                }

                Console.Clear();
                Console.Write($"\nSuccessfully removed student {studentToRemove.FirstName} {studentToRemove.LastName}");
                members.Remove(studentToRemove);
                students.Remove((Student)studentToRemove);
                LoginMenu.PressAnyKey();
                Console.Clear();
                break;

            default:
                Console.Clear();
                Console.WriteLine($"\nNo such option. Please try again.");
                LoginMenu.PressAnyKey();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;
            }

            return(new Tuple <List <Person>, List <Admin>, List <Trainer>, List <Student> >(members, admins, trainers, students));
        }
Пример #13
0
        public static Tuple <List <Person>, List <Admin>, List <Trainer>, List <Student> > AddAMember(List <Person> members, List <Admin> admins, List <Trainer> trainers, List <Student> students, Admin loggedInAdmin)
        {
            Console.Clear();

            Console.WriteLine("\nWould you like to add a new:\n" +
                              "[1] Admin\n" +
                              "[2] Trainer\n" +
                              "[3] Student");


            int adminChoice = int.Parse(Console.ReadLine());

            switch (adminChoice)
            {
            case 1:
                var(adminFirstName, adminLastName, adminUsername, adminPass) = ValidateMember(members);
                Admin newAdmin = new Admin(adminFirstName, adminLastName, adminUsername, adminPass);
                members.Add(newAdmin);
                admins.Add(newAdmin);
                Console.Clear();
                Console.WriteLine($"\nSuccessfully added new Admin!");
                Console.Write($"\nNew admin full name: ");
                newAdmin.PrintInfo();
                Console.WriteLine($"\nNew admin username: {newAdmin.UserName}");
                LoginMenu.PressAnyKey();
                Console.Clear();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;

            case 2:
                var(trainerFirstName, trainerLastName, trainerUsername, trainerPass) = ValidateMember(members);
                Trainer newTrainer = new Trainer(trainerFirstName, trainerLastName, trainerUsername, trainerPass);
                members.Add(newTrainer);
                trainers.Add(newTrainer);
                Console.Clear();
                Console.WriteLine($"\nSuccessfully added new Trainer!");
                Console.Write($"\nNew trainer full name:");
                newTrainer.PrintInfo();
                Console.WriteLine($"\nNew trainer username: {newTrainer.UserName}");
                LoginMenu.PressAnyKey();
                Console.Clear();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;

            case 3:
                var(studentFirstName, studentLastName, studentUsername, studentPass) = ValidateMember(members);
                Student newStudent = new Student(studentFirstName, studentLastName, studentUsername, studentPass, Subject.NoData, new Dictionary <Subject, Grade>());
                members.Add(newStudent);
                students.Add(newStudent);
                Console.Clear();
                Console.WriteLine($"\nSuccessfully added new Student!");
                Console.Write($"\nNew student full name: ");
                newStudent.PrintFullName();
                Console.WriteLine($"\nNew student username: {newStudent.UserName}");
                LoginMenu.PressAnyKey();
                Console.Clear();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;

            default:
                Console.Clear();
                Console.WriteLine($"\nNo such option. Please try again.");
                LoginMenu.PressAnyKey();
                AdminMenu(members, admins, trainers, students, loggedInAdmin);
                break;
            }
            return(new Tuple <List <Person>, List <Admin>, List <Trainer>, List <Student> >(members, admins, trainers, students));
        }