コード例 #1
0
        // update module data
        public void EditModule()
        {
            List <Module> modules = ViewModules();

            if (modules.Count != 0)
            {
                Console.WriteLine("Please type in the module id to edit.");
                int    selected = _optionSelector.SelectIntOption();
                Module module   = _modulePresenter.GetModuleById(selected);

                if (module == null)
                {
                    Console.WriteLine(Environment.NewLine + "Sorry, the module data couldn't be found.");
                }
                else
                {
                    module.ModuleName = InputModuleName();
                    _modulePresenter.EditModule(module);

                    Console.WriteLine(Environment.NewLine + "Successfully updated.");
                }
            }
            else
            {
            }
        }
コード例 #2
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
            {
            }
        }