Beispiel #1
0
        public ActionResult AddActor(MovieActorModel MovieActorModel)
        {
            var AllActor = new SelectList(_ActRep.GetActor().ToList(), "Actor_Id", "Actor_Name");

            ViewData["AllActor"] = AllActor;
            var AllMovie = new SelectList(_MovieRep.GetMovie().ToList(), "Movie_Id", "Movie_Name");

            ViewData["AllMovie"] = AllMovie;

            try
            {
                if (ModelState.IsValid)
                {
                    _MovActRep.AddMovieActor(MovieActorModel);
                    _MovActRep.save();
                    return(Redirect("/MovieActor/Index"));
                }
            }
            catch (DataException e)
            {
                ViewBag.FileStatus = e;
                ModelState.AddModelError("", "Unable to save changes.");
            }

            return(View(MovieActorModel));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         _MovActRep.DeleteMovieActor(id);
         _MovActRep.save();
         return(RedirectToAction("Index"));
     }
     catch (DataException)
     {
         return(RedirectToAction("Delete",
                                 new System.Web.Routing.RouteValueDictionary {
             { "id", id },
             { "saveChangesError", true }
         }));
     }
 }