Ejemplo n.º 1
0
        internal void DisplayCourses()
        {
            int coursesCount = courseController.CourseCount();

            if (coursesCount == 0)
            {
                Console.WriteLine("Total number of live course is zero");
            }
            else
            {
                Dictionary <string, Course> courseList = courseController.RetrieveCourseList();
                foreach (KeyValuePair <string, Course> KeysValuesOfCourseList in courseList)
                {
                    Console.WriteLine("\t\tCourse id: {0}\n" +
                                      "\t\tCourse name: {1}\n" +
                                      "\t\tCourse Description: {2}\n",
                                      KeysValuesOfCourseList.Key,
                                      KeysValuesOfCourseList.Value.Name,
                                      KeysValuesOfCourseList.Value.Description);
                }
            }
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        internal void EnrolStudent()
        {
            if (courseController.CourseCount() == 0)
            {
                Console.WriteLine("Please add course!");
            }
            else if (lecturerController.LecturerCount() == 0)
            {
                Console.WriteLine("Please add lecture!");
            }
            else if (roomController.RoomCount() == 0)
            {
                Console.WriteLine("Please add room!");
            }
            else if (studentController.StudentCount() == 0)
            {
                Console.WriteLine("Please add some students!");
            }
            else if (classController.ClassesCount() == 0)
            {
                Console.WriteLine("Please add class!");
            }
            else
            {
                Console.WriteLine("\t\t** Student List **");
                DisplayStudent();
                Console.Write("\nSelect one student id: ");
                string id = Console.ReadLine();
                while (studentController.SearchStudent(id) == null)
                {
                    Console.WriteLine("student not found!Please try again");
                    Console.Write("> ");
                    id = Console.ReadLine();
                }
                Student student = studentController.SearchStudent(id);

                Console.WriteLine("\t\t** Course List **");
                CourseManagementView coursemv = new CourseManagementView(courseController);
                coursemv.DisplayCourses();
                Console.Write("\nSelect one course id: ");
                string crid = Console.ReadLine();
                while (courseController.SearchCourse(crid) == null)
                {
                    Console.WriteLine("\ncourse not found!Please try again");
                    Console.Write("> ");
                    crid = Console.ReadLine();
                }
                Course course = courseController.SearchCourse(crid);

                ClassManagementView classmv = new ClassManagementView(classController, courseController, lecturerController, roomController);
                classmv.PrintClassOfCourse(crid);
                Console.Write("Please enter a class name to enrol in: ");
                string className = Console.ReadLine();
                //while (classController.SearchClass(className) == null)
                //{
                //    Console.Write("\nClass not found. Try again");
                //    Console.Write("> ");
                //    className = Console.ReadLine();
                //}
                //Class enrolClass = classController.SearchClass(className);
                Class enrolClass = null;
                bool  clashed    = false;
                while (true)
                {
                    enrolClass = classController.SearchClass(className);
                    if (classController.SearchClass(className) == null)
                    {
                        Console.Write("\nClass not found. Try again");
                        Console.Write("> ");
                        className = Console.ReadLine();
                        if (className == "")
                        {
                            clashed = true;
                            break;
                        }
                    }
                    else if (studentController.CheckClashTime(enrolClass, student, classController))
                    {
                        Console.WriteLine("You select a class has period that clashed with your current classes.");
                        Console.Write("You should select different class: ");
                        className = Console.ReadLine();
                        if (className == "")
                        {
                            clashed = true;
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }


                //while (studentController.CheckClashTime(enrolClass, student, classController))
                //{
                //    Console.WriteLine("You select a class has period that clashed with your current classes.");
                //    Console.Write("You should select different class [Enter] to exit: ");
                //    className = Console.ReadLine();
                //    if (className != "")
                //    {
                //        while (classController.SearchClass(className) == null)
                //        {
                //            Console.Write("\nClass not found. Try again");
                //            Console.Write("> ");
                //            className = Console.ReadLine();
                //        }
                //        enrolClass = classController.SearchClass(className);
                //        if (student.GetMyClasses().Count > 4)
                //        {
                //            Console.WriteLine("You are not allowed to add class any more.");
                //        }
                //    }
                //    else
                //        break;
                //}
                if (clashed)
                {
                    Console.WriteLine("Student \"{0}\" failed to enrol class \"{1}\".", id, enrolClass.ToString());
                }
                else
                {
                    if (studentController.EnrolClass(enrolClass, student, classController))
                    {
                        Console.WriteLine("Student \"{0}\" enrolled to class \"{1}\".", id, enrolClass.ToString());
                    }
                }
            }
            Console.Write("[Enter] to continue...");
            Console.ReadLine();
        }