public static StudentCourseEnrollmentJsonModel GetCourseEnrollmentJsonModel(int studentId)
        {
            Student student = GetStudent(studentId);

            if (student == null)
            {
                return(null);
            }

            Department department = DepartmentGateway.GetDepartmentById(student.DepartmentId);

            if (department == null)
            {
                return(null);
            }

            IEnumerable <Course> courses = CourseGateway.GetCoursesByDepartment(student.DepartmentId);

            if (courses == null)
            {
                return(null);
            }


            StudentCourseEnrollmentJsonModel model = new StudentCourseEnrollmentJsonModel
            {
                Name           = student.Name,
                Email          = student.Email,
                DepartmentName = department.Name,
                Courses        = courses
            };

            return(model);
        }
Ejemplo n.º 2
0
        public static IEnumerable <ScheduleInfoViewModel> GetSchedule(int departmentId)
        {
            IEnumerable <Course> courses = CourseGateway.GetCoursesByDepartment(departmentId);

            List <ScheduleInfoViewModel> schedules = null;

            ScheduleInfoViewModel schedule = null;

            if (courses != null)
            {
                schedules = new List <ScheduleInfoViewModel>();

                foreach (Course course in courses)
                {
                    schedule = new ScheduleInfoViewModel
                    {
                        CourseCode = course.Code,
                        CourseName = course.Name,
                        RoomInfo   = GetRoomInfoByCourseId(course.Id)
                    };
                    schedules.Add(schedule);
                }
            }

            return(schedules);
        }