public async Task <AuthorDTO> CreateAuthor(AuthorForCreationDTO author) { var authorEntity = mapper.Map <Author>(author); await authorRepository.Create(authorEntity); return(createLinksStrategy.CreateLinksForAuthorResource(mapper.Map <AuthorDTO>(authorEntity))); }
public async Task <AuthorDTO> GetAuthor(int id) { var author = await authorRepository.GetAuthorById(id); if (author == null) { throw new NotFoundException("Author", id); } return(createLinksStrategy.CreateLinksForAuthorResource(mapper.Map <AuthorDTO>(author))); }
public LinkedCollectionResourceWrapperDTO <AuthorDTO> GetAuthorsCollection(PagingResourceParameters paging) { var authors = authorRepository.GetAllAuthors(paging); var authorsToReturn = mapper.Map <IEnumerable <AuthorDTO> >(authors); authorsToReturn = authorsToReturn.Select(author => { author = createLinksStrategy.CreateLinksForAuthorResource(author); return(author); }); var authorsWrapper = new LinkedCollectionResourceWrapperDTO <AuthorDTO>(authorsToReturn); return(createLinksStrategy.CreateLinksForAuthors(authorsWrapper, paging, authors.HasPrevious, authors.HasNext)); }