Esempio n. 1
0
        //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);
        }
Esempio n. 2
0
        //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"));
        }
Esempio n. 3
0
 //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));
     }
 }
Esempio n. 4
0
        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"));
            }
        }
Esempio n. 5
0
 public IActionResult EnterMovie(EnterMovieModel movieEntered)
 {
     TempStorage.AddMovie(movieEntered);
     return(View("Confirmation"));
 }