Last active
October 13, 2017 20:01
-
-
Save scottsauber/64c6343faec503486933f99934961d52 to your computer and use it in GitHub Desktop.
Simple Web API
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
[Produces("application/json")] | |
[Route("api/ApplicationUsers")] | |
public class ApplicationUsersController : Controller | |
{ | |
private readonly ApplicationDbContext _context; | |
public ApplicationUsersController(ApplicationDbContext context) | |
{ | |
_context = context; | |
} | |
// GET: api/ApplicationUsers/5 | |
[HttpGet("{id}")] | |
public async Task<IActionResult> GetApplicationUser([FromRoute] string id) | |
{ | |
var applicationUser = await _context.Users.SingleOrDefaultAsync(m => m.Id == id); | |
if (applicationUser == null) | |
{ | |
return NotFound(); | |
} | |
return Ok(applicationUser); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment