//
        // GET: /Movie/Create
        //[Authorize(Roles = "Admin")]
        public ActionResult Create()
        {
            //var actors = (from actor in db.Actors
            //              orderby actor.Lastname
            //              select new SelectListItem
            //              {
            //                  Value = actor.ActorID.ToString(),
            //                  Text = actor.Firstname + " " + actor.Lastname
            //              });
            //ViewBag.Actors = new MultiSelectList(actors, "ActorID", "Text");

            Movie movie = new Movie();

            foreach (var item in db.Actors)
            {

            }
            movie.SelectedActors = db.Actors.ToList().Select(a => new SelectListItem
                                {
                                    Text = a.Firstname + " " + a.Lastname,
                                    Value = a.ActorID.ToString()
                                });

            return View(movie);
        }
        public ActionResult Create(Movie movie, Actor actor)
        {
            movie.Actors = db.Actors.Where(a => movie.SelectedActorIds.Contains(a.ActorID)).ToList();

            foreach (var item in movie.Actors)
                item.Movies.Add(movie);

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

            return View(movie);
        }
        public ActionResult Edit(Movie movie)
        {
            movie.Actors = db.Actors.Where(a => movie.SelectedActorIds.Contains(a.ActorID)).ToList();
            if (ModelState.IsValid)
            {
                db.Entry(movie).State=EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(movie);
        }