public IHttpActionResult GetByCourseType(string courseTypeName) { try { var courseTypes = _courseTypeService.FindByName(courseTypeName); var courses = new List <Course>(); foreach (var ct in courseTypes) { courses.AddRange(_courseService.FindByCourseTypeId(ct.Id)); } return(Ok(courses .Select(c => { return GetCourseDto(c); }))); } catch (ArgumentNullException ane) { ModelState.AddModelError("", ane.Message); } return(BadRequest(ModelState)); }
public IHttpActionResult GetByName(string name) { try { var courseTypes = _courseTypeService.FindByName(name); return(Ok(courseTypes .Select(ct => { return GetCourseTypeDto(ct); }))); } catch (ArgumentNullException ane) { ModelState.AddModelError("", ane.Message); } return(BadRequest(ModelState)); }