private ApplicationDbContext _context;
public CustomersController()
{
_context = new ApplicationDbContext();
}
protected override void Dispose(bool disposing)
{
_context.Dispose();
}
public ActionResult Index()
{
var customers = _context.Customers.ToList();
return View(customers);
}
[Route("customers/detail/{index}")]
public ActionResult Detail(int index)
{
var customer = _context.Customers.SingleOrDefault(c => c.Id == index);
if (customer == null)
{
return HttpNotFound();
}
return View(customer);
}