Ejemplo n.º 1
0
        public void HomePage_Faculty()
        {
            bool logout = false;

            while (!logout)
            {
                string answer = EnterValue.AskingValue("Enter what you want to do\n1 : See personal information\n2 : Change personal Information\n3 : Log out", 3);
                switch (answer)
                {
                case "1":
                    Console.WriteLine(userList[currentIndexUser].PersonalInformation());
                    break;

                case "2":
                    string switchAttribute = EnterValue.AskingValue("enter the information you want to change\n1 : email\n2 : password\n3 : nothing", 3);
                    switch (switchAttribute)
                    {
                    case "1":
                        Console.WriteLine("Enter the new email addres");
                        userList[currentIndexUser].Email = Console.ReadLine();
                        break;

                    case "2":
                        Console.WriteLine("Enter the new password");
                        userList[currentIndexUser].Password = Console.ReadLine();
                        break;
                    }
                    break;

                case "3":
                    logout = true;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public bool Login()
        {
            bool succesfullLogin    = false;
            bool endingLoginFuction = false;

            while (!endingLoginFuction)
            {
                Console.WriteLine("Enter your userID");
                int userIDAnswer = Convert.ToInt32(Console.ReadLine());
                if (ContainUserID(userIDAnswer))
                {
                    bool tryingTypePassword = true;
                    while (tryingTypePassword)
                    {
                        string wishAnswer = EnterValue.AskingValue("\nEnter what you want to do\n1 : Enter Password\n2 : Change User ID\n3 : Go back to the first menu", 3);
                        if (wishAnswer == "1")
                        {
                            Console.WriteLine("Enter your password");
                            string answerPassword = Console.ReadLine();
                            if (answerPassword == userList[IndexUserID(userIDAnswer)].Password)
                            {
                                Console.WriteLine("Sucessfully logging");
                                tryingTypePassword = false;
                                endingLoginFuction = true;
                                succesfullLogin    = true;
                                currentIndexUser   = IndexUserID(userIDAnswer);
                            }
                            else
                            {
                                Console.WriteLine("The password entered isn't correct");
                            }
                        }
                        else if (wishAnswer == "2")
                        {
                            tryingTypePassword = false;
                        }
                        else if (wishAnswer == "3")
                        {
                            tryingTypePassword = false;
                            endingLoginFuction = true;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("This userID doesn't exist");
                    string answer = EnterValue.AskingValue("Enter what you want to do\n1 : try again\n2 : go to the first menu", 2);
                    if (answer == "2")
                    {
                        endingLoginFuction = true;
                    }
                }
            }
            return(succesfullLogin);
        }
Ejemplo n.º 3
0
        public int ChoosingDisciplineID()
        {
            int  iDchoosen         = -1;
            bool stayInTheFunction = true;

            while (stayInTheFunction)
            {
                string methodChoiceAnswer = EnterValue.AskingValue("Enter what you want to do\n1 : Choose by enter a discipline ID\n2 : Choose a discipline ID and the see disciplines information\n3 : Go to the previous menu", 3);
                switch (methodChoiceAnswer)
                {
                case "1":
                    Console.WriteLine("Enter the disciplineID");
                    int disciplineIDanswer = Convert.ToInt32(Console.ReadLine());
                    if (ContainDisciplineID(disciplineIDanswer))
                    {
                        iDchoosen         = disciplineIDanswer;
                        stayInTheFunction = false;
                    }
                    else
                    {
                        Console.WriteLine("There is not this discipline ID in the data base");
                    }
                    break;

                case "2":
                    Console.WriteLine("All discipline information :");
                    Console.WriteLine(DisciplinesInformation());
                    Console.WriteLine("Enter the disciplineID of the discipline you want to choose");
                    int disciplineIDChoosen = Convert.ToInt32(Console.ReadLine());
                    if (ContainDisciplineID(disciplineIDChoosen))
                    {
                        iDchoosen         = disciplineIDChoosen;
                        stayInTheFunction = false;
                    }
                    else
                    {
                        Console.WriteLine("There is not this discipline ID in the data base");
                    }
                    break;

                case "3":
                    iDchoosen         = -1;
                    stayInTheFunction = false;
                    break;
                }
            }
            return(iDchoosen);
        }
Ejemplo n.º 4
0
        public int ChoosingAFacultyID()
        {
            int  iDchoosen         = -1;
            bool stayInTheFunction = true;

            while (stayInTheFunction)
            {
                string methodChoiceAnswer = EnterValue.AskingValue("Enter what you want to do\n1 : Choose by enter a user ID of a faculty\n2 : Choose a userID and the faculty information\n3 : Go to the previous menu", 3);
                switch (methodChoiceAnswer)
                {
                case "1":
                    Console.WriteLine("Enter the userID");
                    int userIDAnswer = Convert.ToInt32(Console.ReadLine());
                    if (ContainUserID(userIDAnswer))
                    {
                        if (userList[IndexUserID(userIDAnswer)] is Faculty)
                        {
                            iDchoosen = userIDAnswer;

                            stayInTheFunction = false;
                        }
                        else
                        {
                            Console.WriteLine("The userID is not corresponding to a faculty");
                        }
                    }
                    else
                    {
                        Console.WriteLine("There is not this user ID in the data base");
                    }
                    break;

                case "2":
                    Console.WriteLine("All faculty information :");
                    Console.WriteLine(FacultiesInformation());
                    Console.WriteLine("Enter the UserID of the faculty you want to choose");
                    int userIDChoosen = Convert.ToInt32(Console.ReadLine());
                    if (ContainUserID(userIDChoosen))
                    {
                        if (userList[IndexUserID(userIDChoosen)] is Faculty)
                        {
                            iDchoosen         = userIDChoosen;
                            stayInTheFunction = false;
                        }
                        else
                        {
                            Console.WriteLine("The userID is not corresponding to an faculty");
                        }
                    }
                    else
                    {
                        Console.WriteLine("There is not this user ID in the data base");
                    }
                    break;

                case "3":
                    iDchoosen         = -1;
                    stayInTheFunction = false;
                    break;
                }
            }
            return(iDchoosen);
        }
Ejemplo n.º 5
0
        public bool DisciplineMenu_Administrator()
        {
            bool logout = false;
            bool stayInTheDisciplineMenu = true;

            while (stayInTheDisciplineMenu)
            {
                string disciplineAnswer = EnterValue.AskingValue("Enter what you want to do\n1 : Create a new discipline\n2 : Edit a discipline (you will need the ID of the discipline)\n3 : See discipline information\n4 : Go back to the previous menu\n5 : Log out", 5);
                switch (disciplineAnswer)
                {
                case "1":
                    #region
                    Console.WriteLine("Enter the name of the discipline you want to create");
                    string     nameDiscipline = Console.ReadLine();
                    Discipline newDiscipline  = new Discipline(nameDiscipline);
                    AddDiscipline(newDiscipline);
                    Console.WriteLine($"You add the discipline, the discipline ID is {disciplineList[disciplineList.Count - 1].DisciplineID}");
                    break;

                    #endregion
                case "2":
                    #region
                    Console.WriteLine("Enter the ID of the discipline you want to edit");
                    int disciplineIDAnswer = ChoosingDisciplineID();
                    if (disciplineIDAnswer != -1)
                    {
                        bool stayInChooseFunction = true;
                        while (stayInChooseFunction)
                        {
                            currentIndexDiscipline = IndexDisciplineID(disciplineIDAnswer);
                            string enrollAnswer = EnterValue.AskingValue("Enter what you want to do\n1 : Enroll student\n2 : See all student information\n3 : Enroll a faculty\n4 : See all faculty information\n5 : Go back to the previous menu\n6 : Log out", 6);
                            switch (enrollAnswer)
                            {
                            case "1":
                                #region
                                Console.WriteLine("Enter the ID of the student you want to add");
                                int userIDAnswer = ChoosingStudentID();
                                if (userIDAnswer != -1)
                                {
                                    if (disciplineList[currentIndexDiscipline].EnrollAStudent(userList[IndexUserID(userIDAnswer)]))
                                    {
                                        AddDiscplineAttribute_Student(userIDAnswer, disciplineIDAnswer);
                                        Console.WriteLine($"The student with ID {userIDAnswer} has been added");
                                    }
                                    else
                                    {
                                        Console.WriteLine($"The user with this ID {userIDAnswer} can't be added");
                                    }
                                }
                                break;

                                #endregion
                            case "2":
                                #region
                                Console.WriteLine(StudentsInformation());
                                break;

                                #endregion
                            case "3":
                                #region
                                Console.WriteLine("Enter the ID of the faculty you want to add");
                                int facultyIDAnswer = ChoosingAFacultyID();
                                if (facultyIDAnswer != -1)
                                {
                                    if (disciplineList[currentIndexDiscipline].EnrollAFaculty(userList[IndexUserID(facultyIDAnswer)]))
                                    {
                                        AddDiscplineAttribute_Faculty(facultyIDAnswer, disciplineIDAnswer);
                                        Console.WriteLine($"The faculty with ID {facultyIDAnswer} has been added");
                                    }
                                    else
                                    {
                                        Console.WriteLine($"The user with this ID {facultyIDAnswer} can't be added");
                                    }
                                }
                                break;

                                #endregion
                            case "4":
                                #region
                                Console.WriteLine(FacultiesInformation());
                                break;

                                #endregion
                            case "5":
                                #region
                                stayInChooseFunction = false;
                                #endregion
                                break;

                            case "6":
                                #region
                                stayInChooseFunction    = false;
                                stayInTheDisciplineMenu = false;
                                logout = true;
                                break;
                                #endregion
                            }
                        }
                    }
                    break;

                    #endregion
                case "3":
                    #region
                    Console.WriteLine(DisciplinesInformation());
                    break;

                    #endregion
                case "4":
                    #region
                    stayInTheDisciplineMenu = false;
                    break;

                    #endregion
                case "5":
                    #region
                    stayInTheDisciplineMenu = false;
                    logout = true;
                    break;
                    #endregion
                }
            }
            currentIndexDiscipline = -1;
            return(logout);
        }
Ejemplo n.º 6
0
        public void HomePage_Administrator()
        {
            bool logout = false;

            while (!logout)
            {
                string answer = EnterValue.AskingValue("Enter what you want to do\n1 : See personal information\n2 : Change personal Information\n3 : Go to the discipline menu\n4 : Add a new user\n5 : Log out", 5);
                switch (answer)
                {
                case "1":
                    #region
                    Console.WriteLine(userList[currentIndexUser].PersonalInformation());
                    break;

                    #endregion
                case "2":
                    #region
                    string switchAttribute = EnterValue.AskingValue("enter the information you want to change\n1 : email\n2 : password\n3 : nothing", 3);
                    switch (switchAttribute)
                    {
                    case "1":
                        Console.WriteLine("Enter the new email addres");
                        userList[currentIndexUser].Email = Console.ReadLine();
                        break;

                    case "2":
                        Console.WriteLine("Enter the new password");
                        userList[currentIndexUser].Password = Console.ReadLine();
                        break;
                    }
                    break;

                    #endregion
                case "3":
                    #region
                    logout = DisciplineMenu_Administrator();
                    break;

                    #endregion
                case "4":
                    #region
                    bool   continueAddAUSer = true;
                    string typeAnswer       = EnterValue.AskingValue("Enter what you want to do\n1 : Add a student\n2 : Add a faculty\n3 : Add an administrator\n4 : Go back to the previous menu", 4);
                    {
                        if (typeAnswer == "4")
                        {
                            continueAddAUSer = false;
                        }
                        if (continueAddAUSer)
                        {
                            Console.WriteLine("Enter the first name");
                            string firstNameAnswer = Console.ReadLine();
                            Console.WriteLine("Enter the last name");
                            string lastNameAnswer = Console.ReadLine();
                            Console.WriteLine("Enter the email addres");
                            string emailAnswer = Console.ReadLine();
                            Console.WriteLine("Enter the password for the new user");
                            string passwordAnswer = Console.ReadLine();
                            bool   added          = AddNewUser(typeAnswer, firstNameAnswer, lastNameAnswer, emailAnswer, passwordAnswer);
                            if (added)
                            {
                                Console.WriteLine("\nThe user has been added");
                            }
                            else
                            {
                                Console.WriteLine("\nYou may not have the permission to add the user");
                            }
                        }
                    }
                    break;

                    #endregion
                case "5":
                    #region
                    logout = true;
                    break;
                    #endregion
                }
            }
        }