public ActionResult SaveMovie(Movie movieToBeSaved, string btnSubmit) { if (movieToBeSaved == null) { throw new ArgumentNullException(nameof(movieToBeSaved)); } if (btnSubmit.IsNullOrWhiteSpace()) { throw new ArgumentNullException(nameof(btnSubmit)); } if (btnSubmit.Equals("Add Movie")) { if (ModelState.IsValid) { var blVidly = new VidlyBL(new VidlyDLContext()); blVidly.SaveMovie(movieToBeSaved); return(RedirectToAction("Index")); } return(RedirectToAction("AddNew")); } return(RedirectToAction("Index")); }
// GET: Movies public ActionResult Index() { var blVidly = new VidlyBL(new VidlyDLContext()); var viewModel = new ShowMoviesViewModel { AllMovies = blVidly.GetMovies() }; //view with different name then action return(View("Index", viewModel)); }