Exemplo n.º 1
0
        public ActionResult <CourseDto> CreateCourseForAuthor(Guid authorId, NewCourseDto course)
        {
            var newCourse = _manager.AddCourseForAuthor(authorId, course);

            return(newCourse == null?NotFound() : (ActionResult <CourseDto>)CreatedAtRoute("GetCourseForAuthor",
                                                                                           new { authorId, courseId = newCourse.Id }, newCourse));
        }
Exemplo n.º 2
0
        public CourseDto AddCourseForAuthor(Guid authorId, NewCourseDto course)
        {
            if (!_repo.AuthorExists(authorId))
            {
                return(null);
            }
            var courseEntity = _mapper.Map <Course>(course);

            _repo.AddCourse(authorId, courseEntity);
            _repo.Save();
            return(_mapper.Map <CourseDto>(courseEntity));
        }