Ejemplo n.º 1
0
        public IActionResult GetAuthor(Guid id)
        {
            var author = _repository.GetAuthor(id);

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

            return(Ok(_mapper.Map <AuthorDto>(author)));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public IActionResult Get(int authorsId)
 {
     if (!authorsRepository.AuthorExists(authorsId))
     {
         return(NotFound());
     }
     return(Ok(authorsRepository.GetAuthor(authorsId)));
 }
Ejemplo n.º 4
0
        private void ValidateAuthor(int authorId)
        {
            var author = authorsRepository.GetAuthor(authorId);

            if (author == null)
            {
                throw new NotFoundException($"author with id {authorId} not found");
            }
        }
Ejemplo n.º 5
0
        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)));
 }