public ActionResult <CourseDto> Post([FromBody] CourseDto course) { var createResult = _courseService.CreateCourse(course.ToModel()); if (createResult.HasErrors) { return(BadRequest(createResult.Errors)); } return(Accepted(CourseDto.FromModel(createResult.Result))); }
public ActionResult <CourseDto> Get(int id) { var course = _courseService.GetCourseById(id); if (course == null) { return(NotFound()); } return(Ok(CourseDto.FromModel(course))); }
public ActionResult <IEnumerable <CourseDto> > Get() { return(Ok(_courseService.GetAllCourses().Select(course => CourseDto.FromModel(course)))); }
public ActionResult <CourseDto> Post([FromBody] CourseDto course) { var createdCourse = _courseService.CreateCourse(course.ToModel()); return(Accepted(CourseDto.FromModel(createdCourse))); }