public ActionResult Create(CreateViewModel vm) { if (ModelState.IsValid) { var movieToCreate = new Movie { Title = vm.Title, Director = vm.Director }; repository.Create(movieToCreate); try { repository.SaveChanges(); } catch (DbEntityValidationException dex) { ModelState.Merge(dex.GetModelErrors()); return View(vm); } return RedirectToAction("Index"); } return View(vm); }
public void Create(Movie movieToCreate) { dataContext.Movies.Add(movieToCreate); }