Movies included in database as well and handled in site

This commit is contained in:
2019-01-21 20:52:22 +01:00
parent 19fc2475fa
commit f5a597fcdb
33 changed files with 1418 additions and 59 deletions

View File

@ -11,19 +11,11 @@ namespace Vidly.Controllers
{
public class CustomersController : Controller
{
List<Customer> customers = null;
private ApplicationDbContext _context;
public CustomersController()
{
_context = new ApplicationDbContext();
customers = new List<Customer>
{
new Customer {Name="Nils Persson", Id=1},
new Customer {Name="Pelle Rundström",Id=2},
new Customer {Name="Ulla Ulriksson",Id=3}
};
}
protected override void Dispose(bool disposing)
@ -51,7 +43,7 @@ namespace Vidly.Controllers
[Route("Customers/Details/{nr}")]
public ActionResult Customer(int nr)
{
var customer = _context.Customers.SingleOrDefault(c => c.Id == nr);
var customer = _context.Customers.Include(c => c.MembershipType).SingleOrDefault(c => c.Id == nr);
if (customer== null)
return HttpNotFound();
return View(customer);