public async Task <IActionResult> BlockAuthorCreation(Guid id) { if (await _libraryRepository.AuthorExistsAsync(id)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } return(NotFound()); }
public async Task <IActionResult> GetBooksAuthor(Guid authorId) { if (!(await _libraryRepository.AuthorExistsAsync(authorId))) { return(NotFound()); } var booksFromRepository = await _libraryRepository.GetBooksForAuthorAsync(authorId); var booksForAuthor = AutoMapper.Mapper.Map <IEnumerable <BookDto> >(booksFromRepository); return(Ok(booksForAuthor)); }
public async Task <ActionResult <IEnumerable <BookDto> > > GetBooksForAuthorAsync(Guid authorId) { if (!await _libraryRepository.AuthorExistsAsync(authorId)) { return(NotFound()); } var booksFromRepo = await _libraryRepository.GetBooksForAuthorAsync(authorId); var booksForAuthor = _mapper.Map <IEnumerable <BookDto> >(booksFromRepo); booksForAuthor = booksForAuthor.Select(book => CreateLinksForBook(book)); var wrapper = new LinkedCollectionResourceWrapperDto <BookDto>(booksForAuthor); return(Ok(CreateLinksForBook(wrapper))); }