Last active
May 5, 2019 13:12
-
-
Save nishanc/55d8b650074627c8fad7a3edd79fd7b0 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using JWTAuth.API.Data; | |
using Microsoft.EntityFrameworkCore; | |
namespace JWTAuth.API.Controllers | |
{ | |
[Route("api/[controller]")] | |
[ApiController] | |
public class ValuesController : ControllerBase | |
{ | |
private readonly DataContext _context; | |
public ValuesController(DataContext context) | |
{ | |
_context = context; | |
} | |
// GET api/values | |
[HttpGet] | |
public async Task<IActionResult> GetValues() | |
{ | |
var values = await _context.Values.ToListAsync(); | |
return Ok(values); | |
} | |
// GET api/values/5 | |
[HttpGet("{id}")] | |
public async Task<IActionResult> GetValue(int id) | |
{ | |
var value = await _context.Values.FirstOrDefaultAsync(x => x.Id == id); | |
return Ok(value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment