Exemple #1
0
        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)));
        }
Exemple #2
0
        public ActionResult <CourseDto> Get(int id)
        {
            var course = _courseService.GetCourseById(id);

            if (course == null)
            {
                return(NotFound());
            }

            return(Ok(CourseDto.FromModel(course)));
        }
Exemple #3
0
 public ActionResult <IEnumerable <CourseDto> > Get()
 {
     return(Ok(_courseService.GetAllCourses().Select(course => CourseDto.FromModel(course))));
 }
Exemple #4
0
        public ActionResult <CourseDto> Post([FromBody] CourseDto course)
        {
            var createdCourse = _courseService.CreateCourse(course.ToModel());

            return(Accepted(CourseDto.FromModel(createdCourse)));
        }