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) }); }
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)); }
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)); }