示例#1
0
        public IActionResult GetAuthor(Guid id)
        {
            var author = _repository.GetAuthor(id);

            if (author == null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <AuthorDto>(author)));
        }
示例#2
0
        public async Task <Models.Author> GetAuthor(int?id)
        {
            var result = await _authorRepository.GetAuthor(id);

            Models.Author author = _mapper.Map <Models.Author>(result);
            return(author);
        }
示例#3
0
 public IActionResult Get(int authorsId)
 {
     if (!authorsRepository.AuthorExists(authorsId))
     {
         return(NotFound());
     }
     return(Ok(authorsRepository.GetAuthor(authorsId)));
 }
示例#4
0
        private void ValidateAuthor(int authorId)
        {
            var author = authorsRepository.GetAuthor(authorId);

            if (author == null)
            {
                throw new NotFoundException($"author with id {authorId} not found");
            }
        }
        public Author GetAuthor(int id, bool showBooks)
        {
            var author = authorsRepository.GetAuthor(id);

            if (author == null)
            {
                throw new NotFoundException("author not found");
            }

            if (showBooks)
            {
                author.books = authorsRepository.GetBooks().Where(b => b.AuthorId == author.Id);
            }
            else
            {
                author.books = null;
            }

            return(author);
        }
 public IActionResult Get(int authorId)
 {
     return(Ok(authorsRepository.GetAuthor(authorId)));
 }