Last active
March 11, 2021 20:32
-
-
Save mzorec/4ec5c850364c43f174f5bdf3dfd6b07c to your computer and use it in GitHub Desktop.
.net core rest api method example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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