Skip to content

Instantly share code, notes, and snippets.

@mzorec
Last active March 11, 2021 20:32
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 mzorec/4ec5c850364c43f174f5bdf3dfd6b07c to your computer and use it in GitHub Desktop.
Save mzorec/4ec5c850364c43f174f5bdf3dfd6b07c to your computer and use it in GitHub Desktop.
.net core rest api method example
[HttpGet("{id}")]
public async Task<ActionResult<TodoItem>> GetTodoItem(long id)
{
var todoItem = await _context.TodoItems.FindAsync(id);
if (todoItem == null)
{
return NotFound();
}
return todoItem;
}
public class TodoItem
{
public long Id { get; set; }
public string Name { get; set; }
public bool IsComplete { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment