Skip to content

Instantly share code, notes, and snippets.

@emrekizildas
Created March 19, 2019 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emrekizildas/9d4471b0ae71d93902f8bb6370f0f81a to your computer and use it in GitHub Desktop.
Save emrekizildas/9d4471b0ae71d93902f8bb6370f0f81a to your computer and use it in GitHub Desktop.
[HttpGet]
public async Task<IActionResult> GetBooks()
{
List<BookInfoDto> books = await _db.Books
.Select(x => new BookInfoDto() { BookID = x.BookID, Name = x.Name, AuthorName = x.Author.Name })
.ToListAsync();
if (books.Count() == 0)
return NotFound();
return Ok(books);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment