示例#1
0
        public async Task <AuthorDTO> CreateAuthor(AuthorForCreationDTO author)
        {
            var authorEntity = mapper.Map <Author>(author);
            await authorRepository.Create(authorEntity);

            return(createLinksStrategy.CreateLinksForAuthorResource(mapper.Map <AuthorDTO>(authorEntity)));
        }
示例#2
0
        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)));
        }
示例#3
0
        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));
        }