public ActionResult Create()
 {
     Movie movie = new Movie();
     movie.ActorSelections = db.Actors.ToList().Select(a => new SelectListItem
     {
         Text = a.FirstName + " " + a.LastName,
         Value = a.Id.ToString()
     });
     return View(movie);
 }
        public ActionResult Create(Movie movie)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }
        public ActionResult Create(Movie movie)
        {
            movie.Actors = db.Actors.Where(a => movie.ActorSelectionIds.Contains(a.Id)).ToList();
            foreach (var actor in movie.Actors)
            {
                actor.Movies.Add(movie);
                TryValidateModel(actor, "");
                db.Entry(actor).State = EntityState.Modified;
            }

            if (ModelState.IsValid)
            {
                db.Movies.Add(movie);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }
 public ActionResult Edit(Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(movie);
 }