Skip to content

Instantly share code, notes, and snippets.

@emrekizildas
Last active March 19, 2019 14:40
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/5cea3fa5bca4ebc8300c4c33d37a898a to your computer and use it in GitHub Desktop.
Save emrekizildas/5cea3fa5bca4ebc8300c4c33d37a898a to your computer and use it in GitHub Desktop.
[HttpGet("{id}")]
public async Task<ActionResult<BookInfoDto>> GetBook(int id)
{
BookInfoDto book = await _db.Books
.Select(x => new BookInfoDto() { BookID = x.BookID, Name = x.Name, AuthorName = x.Author.Name })
.SingleOrDefaultAsync(x => x.BookID == id);
if (book == null)
return NotFound("İstenilen kitap bulunamadı");
return Ok(book);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment