//this action just takes the correct movie int from a hidden form, and then sends it to the action with the correct object for it to populate the form public IActionResult Edit(int movieid) { EnterMovieModel movie = (EnterMovieModel)_context.Movies.Where(r => r.movieId == movieid).FirstOrDefault(); return(View("Update", movie)); //_context.Update(movie); }
//just finds the right object in the database based on the movieid, and then deletes from the database public IActionResult Delete(int movieId) { EnterMovieModel movie = (EnterMovieModel)_context.Movies.Where(r => r.movieId == movieId).FirstOrDefault(); _context.Movies.Remove(movie); _context.SaveChanges(); return(View("Confirmation")); }
//checks if its valid, then updates the movie, saves, and sends you to a confirmation page public IActionResult Update(EnterMovieModel movie) { if (ModelState.IsValid) { _context.Movies.Update(movie); _context.SaveChanges(); return(View("Confirmation")); } else { return(View("Update", movie)); } }
public IActionResult EnterMovie(EnterMovieModel movieEntered) { //Here is where we need to create the object with the model if (ModelState.IsValid) { _context.Movies.Add(movieEntered); _context.SaveChanges(); return(RedirectToAction("ViewMovies")); } else { return(View("EnterMovie")); } }
public IActionResult EnterMovie(EnterMovieModel movieEntered) { TempStorage.AddMovie(movieEntered); return(View("Confirmation")); }