public IActionResult GetAuthor(Guid id) { var author = _repository.GetAuthor(id); if (author == null) { return(NotFound()); } return(Ok(_mapper.Map <AuthorDto>(author))); }
public async Task <Models.Author> GetAuthor(int?id) { var result = await _authorRepository.GetAuthor(id); Models.Author author = _mapper.Map <Models.Author>(result); return(author); }
public IActionResult Get(int authorsId) { if (!authorsRepository.AuthorExists(authorsId)) { return(NotFound()); } return(Ok(authorsRepository.GetAuthor(authorsId))); }
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))); }