public IActionResult GetBooksForAuthor(Guid authorid) { if (!_repo.AuthorExists(authorid)) { return(NotFound()); } var booksForAuthorFromRepo = _repo.GetBooksForAuthor(authorid); var booksForAuthor = Mapper.Map <IEnumerable <BooksDto> >(booksForAuthorFromRepo); if (booksForAuthor == null) { return(NotFound()); } booksForAuthor = booksForAuthor.Select(book => { book = CreateLinksForBooks(book); return(book); }); var wrapper = new LinksCollectionResourceWrapperDto <BooksDto>(booksForAuthor); return(Ok(CreateLinksForBooks(wrapper))); }
private LinksCollectionResourceWrapperDto <BooksDto> CreateLinksForBooks( LinksCollectionResourceWrapperDto <BooksDto> booksWrapper) { // link to self booksWrapper.Links.Add( new LinkDto(_urlHelper.Link("GetBooksForAuthor", new { }), "self", "GET")); return(booksWrapper); }