public ActionResult AddMovie() { var femaleActors = this.actorsRepo .All() .Select(ActorViewModel.FromActor) .Where(a => a.IsFemale) .ToList(); var maleActors = this.actorsRepo .All() .Select(ActorViewModel.FromActor) .Where(a => !a.IsFemale) .ToList(); var studios = this.studiosRepo .All() .Select(StudioViewModel.FromStudio) .ToList(); var model = new MovieAddViewModel() { FemaleActors = femaleActors, MaleActors = maleActors, Studios = studios }; return View("_PartialAddMovie", model); }
public ActionResult AddMovie(MovieAddViewModel model) { if (ModelState.IsValid) { return this.RedirectToAction("AddMovie", "Movies", model); } else { return this.PartialView("Error"); } }
public ActionResult AddMovie(MovieAddViewModel movie) { var femaleLead = this.actorsRepo.GetById(movie.SelectedFemaleLeadId); var maleLead = this.actorsRepo.GetById(movie.SelectedMaleLeadId); var studio = this.studioRepo.GetById(movie.SelectedStudioId); this.moviesRepo.Add(new Movie() { Title = movie.Title, Director = movie.Director, Year = movie.Year, FemaleLead = femaleLead, MaleLead = maleLead, Studio = studio }); this.moviesRepo.SaveChanges(); return this.RedirectToAction("Index"); }