Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class CustomerController : Controller
private readonly NorthwindSlimContext _context;
public CustomerController(NorthwindSlimContext context)
_context = context;
// GET: api/Customer
public async Task<IActionResult> GetCustomers()
var customers = await _context.Customers
return Ok(customers);
// GET: api/Customer/ALFKI
public async Task<IActionResult> GetCustomer([FromRoute] string id)
var customer = await _context.Customers.SingleOrDefaultAsync(m => m.CustomerId == id);
if (customer == null)
return NotFound();
return Ok(customer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment