Exemple #1
0
        // show which modules student takes by selecting student id
        public void ViewStudentModuleByStudentId()
        {
            List <Student> students = _studentView.ViewStudents();

            Console.WriteLine(Environment.NewLine);

            if (students.Count != 0)
            {
                Console.WriteLine("Please type in the student id to check which modules he/she takes.");
                int     studentId = _optionSelector.SelectIntOption();
                Student student   = _studentPresenter.GetStudentById(studentId);
                List <StudentModule> studentModules = _studentModulePresenter.GetStudentModuleByStudentId(studentId);

                if (student != null)
                {
                    if (studentModules.Count != 0)
                    {
                        bool once = true;
                        foreach (StudentModule studentModule in studentModules)
                        {
                            if (once)
                            {
                                Console.WriteLine("[Student Info]" + Environment.NewLine);
                                _studentView.ShowStudentEachData(studentModule.Student);
                                Console.WriteLine(Environment.NewLine + "[Module Info of the student's]");
                                once = false;
                            }

                            Console.WriteLine($"Module Id: {studentModule.Module.ModuleId}  Module Name: {studentModule.Module.ModuleName}");
                        }
                    }

                    else
                    {
                        Console.WriteLine("The student doesn't take any module so far.");
                    }
                }
                else
                {
                    Console.WriteLine("Sorry, the student data couldn't be found.");
                }
            }
            else
            {
            }
        }
        public void DisplayStudentPage()
        {
            Console.WriteLine("########## You can select your action below. ##########" + Environment.NewLine);
            Console.WriteLine("Register new student data         : 1 {0}" +
                              "Show the specified student data   : 2 {0}" +
                              "Show all the students data        : 3 {0}" +
                              "Edit the specified student data   : 4 {0}" +
                              "Delete the specified student data : 5 {0}" +
                              "Go back to the previous page      : 0 {0}", Environment.NewLine);

            string selected = _optionSelector.SelectStringOption();

            switch (selected)
            {
            case "1":
                _studentView.RegisterStudent();
                break;

            case "2":
                _studentView.ViewStudent();
                break;

            case "3":
                _studentView.ViewStudents();
                break;

            case "4":
                _studentView.EditStudent();
                break;

            case "5":
                _studentView.DeleteStudent();
                break;

            case "0":
                break;
            }

            _optionSelector.PressKey();
        }