February 2010
Beginner
400 pages
11h 13m
English
You will now create a page to display a list of all the films. You need to add this functionality to the controller.
Open the file ~/Controllers/FilmController.cs.
Add the following code at the top of the class to get an instance of the FilmRepository:
BobsMoviesMVC.Models.IFilmRepository filmRepository;
public FilmController()
{
filmRepository = new BobsMoviesMVC.Models.FilmRepository();
}
You might think there are easier ways of doing this (and you would be right), but this sets you up nicely for testing the application. Now add the following action to retrieve a list of all the films:
public ActionResult All()
{
return View(filmRepository.GetAll());
}
Right-click the ~/Views/Film directory, and select Add New ...