Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Last active October 13, 2017 20:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scottsauber/64c6343faec503486933f99934961d52 to your computer and use it in GitHub Desktop.
Simple Web API
[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