public async Task <IActionResult> UpdateCourseForAuthor(Guid authorId,
                                                                Guid courseId,
                                                                CourseUpdateDto course)
        {
            //Check if author exists
            if (!await _authorRepository.AuthorExistsAsync(authorId))
            {
                return(NotFound());
            }

            //Check if course exists
            var courseForAuthorEntity = await _courseRepository.GetCourseAsync(authorId, courseId);

            if (courseForAuthorEntity == null)
            {
                // return NotFound();
                // Upsert pattern - need to create the course
                var courseToAdd = _mapper.Map <Course>(course);
                // Get course Id from URI
                courseToAdd.Id = courseId;
                await _courseRepository.AddCourseAsync(authorId, courseToAdd);

                //201 return - correct sc since a new resource has been created.
                var courseToReturn = _mapper.Map <CourseDto>(courseToAdd);
                return(CreatedAtRoute("GetCourseForAuthor",
                                      new { authorId, courseId = courseToReturn.Id }, courseToReturn));
            }

            // EF core - tracker marks entity as modified.
            _mapper.Map(course, courseForAuthorEntity);
            await _courseRepository.UpdateCourseAsync(courseForAuthorEntity);

            // Status code 204 - no content returned
            return(NoContent());
        }