public ActionResult Reset() { using (var ctx = new MovieContext()) { ctx.Database.ExecuteSqlCommand("TRUNCATE TABLE [Movies]"); } return new RedirectResult("~/"); }
public ActionResult Add() { using (var ctx = new MovieContext()) { ctx.Movies.Add(new Movie {Title = "My Movie " + DateTime.UtcNow.ToString("o") + " (manual)"}); ctx.SaveChanges(); } return new RedirectResult("~/"); }
public ActionResult Index() { MoviesViewModel viewModel; using (var ctx = new MovieContext()) { var movies = ctx.Movies.ToArray(); viewModel = new MoviesViewModel(movies); } return View(viewModel); }