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); }
public JsonResult GetStudentInfo(int studentId) { StudentCourseEnrollmentJsonModel jsonModel = StudentGateway.GetCourseEnrollmentJsonModel(studentId); return(Json(jsonModel, behavior: JsonRequestBehavior.AllowGet)); }