示例#1
0
 public static CourseSectionDto From(Model.CourseSection section)
 {
     return(new CourseSectionDto {
         Id = section.Id,
         SemesterTermId = section.Semester.Id,
         SectionNumber = section.SectionNumber,
         CatalogCourse = CatalogCourseDto.From(section.CatalogCourse)
     });
 }
示例#2
0
        public CatalogCourseDto GetCourse(int id)
        {
            var course = mContext.Courses.Where(c => c.Id == id).SingleOrDefault();

            if (course == null)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(
                                                    HttpStatusCode.NotFound, $"No course with id {id} found"));
            }
            return(CatalogCourseDto.From(course));
        }
示例#3
0
        public CatalogCourseDto GetCourse([FromUri] string name)
        {
            var course = mContext.Courses.Where(c => c.DepartmentName + " " + c.CourseNumber == name)
                         .SingleOrDefault();

            if (course == null)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(
                                                    HttpStatusCode.NotFound, $"No course with name {name} found"));
            }
            return(CatalogCourseDto.From(course));
        }