using System.Web.Mvc; using MvcApplication1.Models; namespace MvcApplication1.Controllers { public class ProductController : Controller { private IProductRepository _repository; public ProductController(): this(new ProductRepository()) {} public ProductController(IProductRepository repository) { _repository = repository; } public ActionResult Index() { return View(_repository.ListProducts()); } // // GET: /Product/Create public ActionResult Create() { return View(); } // // POST: /Product/Create [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Exclude="Id")] Product productToCreate) { _repository.CreateProduct(productToCreate); return RedirectToAction("Index"); } } }