Created
August 28, 2014 17:19
-
-
Save ardalis/7c93ddf2bc191d816faf to your computer and use it in GitHub Desktop.
Loosely Coupled Controller Index
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.Data.Entity; | |
using System.Net; | |
using System.Web.Mvc; | |
using MvcMovie.Core.Interfaces; | |
using MvcMovie.Infrastructure.Data; | |
using MvcMovie.Infrastructure.Data.Repositories; | |
using MvcMovie.Models; | |
namespace MvcMovie.Controllers | |
{ | |
public class MoviesController : Controller | |
{ | |
private readonly IMovieRepository _movieRepository; | |
private MovieDbContext db = new MovieDbContext(); | |
public MoviesController(IMovieRepository movieRepository) | |
{ | |
_movieRepository = movieRepository; | |
} | |
public MoviesController() | |
: this(new EfMovieRepository()) | |
{ } | |
// GET: /Movies/ | |
public ActionResult Index(string movieGenre, string searchString) | |
{ | |
ViewBag.movieGenre = | |
new SelectList(_movieRepository.ListGenres()); | |
return View(_movieRepository.ListMovies(movieGenre, searchString)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment