コード例 #1
0
        public ActionResult ApiJson(string semesterID, string departmentID, string courseID)
        {
            if(!string.IsNullOrEmpty(semesterID) && !string.IsNullOrEmpty(departmentID))
            {
                List<Course> courses = new List<Course>();
                CourseListingDataAccess dataAccess = new CourseListingDataAccess(RavenSession);

                if (string.IsNullOrEmpty(courseID))
                {
                    courses = dataAccess.GetCoursesBySemesterIDandDepartmentID(semesterID, departmentID);
                }
                else
                {
                    courses = dataAccess.GetCourses(semesterID, departmentID, courseID);
                }

                MvcJsonResult jsonNetResult = new MvcJsonResult();
                jsonNetResult.Formatting = Formatting.Indented;
                jsonNetResult.Data = courses;

                return jsonNetResult;
            }
            else
            {
                return RedirectToAction("ApiHelp", "Assignments");
            }
        }
コード例 #2
0
        public ActionResult ApiXml(string semesterID, string departmentID, string courseID)
        {
            if(!string.IsNullOrEmpty(semesterID) && !string.IsNullOrEmpty(departmentID))
            {
                List<Course> courses = new List<Course>();
                CourseListingDataAccess dataAccess = new CourseListingDataAccess(RavenSession);

                if(string.IsNullOrEmpty(courseID))
                {
                    courses = dataAccess.GetCoursesBySemesterIDandDepartmentID(semesterID, departmentID);
                }
                else
                {
                    courses = dataAccess.GetCourses(semesterID, departmentID, courseID);
                }

                return new MvcXmlResult(courses);
            }
            else
            {
                return RedirectToAction("ApiHelp", "Assignments");
            }
        }