Example #1
0
        public IActionResult Add_Movie(Add_Movie_Data new_Movie)
        {
            /* Logic to make sure that the movie Independence Day is never properly processed*/
            if (ModelState.IsValid == true)
            {
                if (new_Movie.Movie_Title.ToUpper() != "INDEPENDENCE DAY")
                {
                    //Communicates with the sqlite database through the private context object to modify data in the database
                    _context.Movies.Add(new_Movie);
                    _context.SaveChanges();

                    return(View("Confirmation", new_Movie));
                }
                else
                {
                    //Return the confirmation page with error messages for tyring to enter "independence day" as a movie
                    return(View("Confirmation", new_Movie));
                }
            }
            else
            {
                //Reload the page in a way that allows mistyped info to be called-out
                return(View(new_Movie));
            }
        }
Example #2
0
        public IActionResult Remove_Movie(Add_Movie_Data movie_to_remove)
        {
            //IQueryable object that finds the desired record in the sqlite database to remove
            IQueryable <Add_Movie_Data> removing_record = _context.Movies.Where(p => p.MovieID == movie_to_remove.MovieID);

            //loop to remove the record in the database
            foreach (var x in removing_record)
            {
                _context.Movies.Remove(x);
            }

            _context.SaveChanges();

            return(View("Edit_Confirmation", movie_to_remove));
        }
Example #3
0
        public IActionResult Edit_Movie(Add_Movie_Data movie_to_edit)
        {
            if (ModelState.IsValid == true)
            {
                if (movie_to_edit.Movie_Title.ToUpper() != "INDEPENDENCE DAY")
                {
                    //Create an Iqueryable object that returns the one specific record that is being edited
                    IQueryable <Add_Movie_Data> editing_movie = _context.Movies.Where(p => p.MovieID == movie_to_edit.MovieID);

                    //loop to edit the data of the desired record
                    foreach (var x in editing_movie)
                    {
                        x.Movie_Title = movie_to_edit.Movie_Title;
                        x.Category    = movie_to_edit.Category;
                        x.Director    = movie_to_edit.Director;
                        x.Rating      = movie_to_edit.Rating;
                        x.Year        = movie_to_edit.Year;
                        x.Lent_To     = movie_to_edit.Lent_To;
                        x.Edited      = movie_to_edit.Edited;
                        x.Notes       = movie_to_edit.Notes;
                    }

                    _context.SaveChanges();

                    //Then return a customized confirmation page that confirms that the record has been modified/edited
                    return(View("Edit_Confirmation", movie_to_edit));
                }

                else
                {
                    //Return the confirmation page with error messages for tyring to enter "independence day" as a movie
                    return(View("Edit_Confirmation", movie_to_edit));
                }
            }

            else
            {
                return(View(movie_to_edit));
            }
        }
Example #4
0
 public IActionResult My_Movies(Add_Movie_Data movie_to_edit)
 {
     return(View("Edit_Movie", movie_to_edit));
 }