private LinkedColletionResourceWeapperDto <BookDto> CreateLinksForBooks( LinkedColletionResourceWeapperDto <BookDto> booksWrapper) { booksWrapper.Links.Add( new LinkDto(_urlHelper.Link("GetBooksForAuthor", new { }), "self", "GET")); return(booksWrapper); }
public IActionResult GetBooksForAuthor(Guid authorId) { if (!_libraryRepository.AuthorExists(authorId)) { return(NotFound()); } var booksForAuthorFromRepo = _libraryRepository.GetBooksForAuthor(authorId); var booksForAuthor = Mapper.Map <IEnumerable <BookDto> >(booksForAuthorFromRepo); booksForAuthor = booksForAuthor.Select(book => { book = CreateLinksForBook(book); return(book); }); var wrapper = new LinkedColletionResourceWeapperDto <BookDto>(booksForAuthor); return(Ok(CreateLinksForBooks(wrapper))); }