private static void generateTestReview(string review, Movie movie, string user)
        {
            string[] tokens = review.Split('|');

            string rating = tokens[0];
            string content = "";

            for(int i = 1; i < tokens.Length; i++)
            {
                if (tokens[i].Equals("MOV"))
                {
                    content += movie.title;
                }
                else if(tokens[i].Equals("DIR"))
                {
                    content += movie.director;
                }
                else if (tokens[i].Equals("LEN"))
                {
                    content += movie.length;
                }
                else if (tokens[i].Equals("GEN"))
                {
                    content += movie.genres[0];
                }
                else
                {
                    content += tokens[i];
                }
            }

            ReviewManager.createReview(user, movie.title, rating, content);
        }
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                List<Movie> movies = (List<Movie>)dataGridView.DataSource;
                Movie[] movs = new Movie[movies.Count];
                movies.CopyTo(movs);
                Movie movie = movs[e.RowIndex];

                ApplicationManager.changeForm("MOVIE", new Movie(movie));
            }
            else if(laskClickedColumn == e.ColumnIndex)
            {
                List<Movie> movies = (List<Movie>)dataGridView.DataSource;
                movies.Reverse();
                dataGridView.Refresh();
            }
            else
            {
                if (e.ColumnIndex == 0)
                {
                    MovieManager.sortByTitle(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 1)
                {
                    MovieManager.sortByYear(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 2)
                {
                    MovieManager.sortByLength(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 3)
                {
                    MovieManager.sortByCertification(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 4)
                {
                    MovieManager.sortByDirector(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 5)
                {
                    MovieManager.sortByRating(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 6)
                {
                    MovieManager.sortByGenres(((List<Movie>)dataGridView.DataSource));
                }
                else if (e.ColumnIndex == 7)
                {
                    MovieManager.sortByActors(((List<Movie>)dataGridView.DataSource));
                }

                laskClickedColumn = e.ColumnIndex;
                dataGridView.Refresh();
            }
        }
 public Movie(Movie m)
 {
     title = m.title;
     year = m.year;
     length = m.length;
     certification = m.certification;
     director = m.director;
     rating = m.rating;
     genres = m.genres;
     actors = m.actors;
     genreList = m.genreList;
     actorList = m.actorList;
 }
        private void fillInPage(Movie movie)
        {
            movieTitleLabel.Text = movie.title;
            yearLabel.Text = "(" + movie.year + ")";
            ratingLabel.Text = "Rating: " + movie.rating;

            certificationLabel.Text = movie.certification.Length > 0 ? "Certification: " + movie.certification : "";

            genreList.Items.Clear();

            genreList.Items.Add("Genres:");

            foreach(string genre in movie.genreList)
            {
                genreList.Items.Add(genre);
            }

            genreList.BackColor = BackColor;

            directorLabel.Text = "Director: " + movie.director;
            lengthLabel.Text = "Length: " + movie.length + " min";

            actorList.Items.Clear();

            actorList.Items.Add("Actors:");

            foreach (string actor in movie.actorList)
            {
                actorList.Items.Add(actor);
            }

            if(ApplicationManager.loggedIn == null)
            {
                addToListButton.Hide();
            }
            else
            {
                addToListButton.Show();
            }

            fillInReviews(movie.title);
        }
        private void viewMoviePage(object sender, DataGridViewCellEventArgs e)
        {
            if(e.RowIndex > -1)
            {
                List<Movie> movies = (List<Movie>)dataGridView1.DataSource;
                Movie[] movs = new Movie[movies.Count];
                movies.CopyTo(movs);
                Movie movie = movs[e.RowIndex];

                ApplicationManager.changeForm("MOVIE", new Movie(movie));
            }
            else if(lastClicked == e.ColumnIndex)
            {
                List<Movie> movies = (List<Movie>)dataGridView1.DataSource;
                movies.Reverse();
                dataGridView1.Refresh();
            }
            else
            {
                Console.WriteLine(e.ColumnIndex);
                if (e.ColumnIndex == 0)
                {
                    MovieManager.sortByTitle(((List<Movie>)dataGridView1.DataSource));
                }
                else if (e.ColumnIndex == 1)
                {
                    MovieManager.sortByYear(((List<Movie>)dataGridView1.DataSource));
                }
                else if (e.ColumnIndex == 5)
                {
                    MovieManager.sortByRating(((List<Movie>)dataGridView1.DataSource));
                }
                else if (e.ColumnIndex == 6)
                {
                    MovieManager.sortByGenres(((List<Movie>)dataGridView1.DataSource));
                }

                lastClicked = e.ColumnIndex;
                dataGridView1.Refresh();
            }
        }
        private bool checkGenres(Movie movie)
        {
            bool match = false;
            List<string> genres = movie.genreList;

            // If all genres are false, accept
            if (!action && !comedy && !family && !history && !mystery && !scifi &&
                !war && !adventure && !crime && !fantasy && !horror && !news &&
                !sport && !western && !animation && !documentary && !filmnoir && !music
                && !realitytv && !talkshow && !biography && !drama && !gameshow && !musical
                && !romance && !thriller)
            {
                match = true;
            }
            // If one of these is true, accept
            else if ((action && genres.Contains("Action")) || (comedy && genres.Contains("Comedy")) ||
                (family && genres.Contains("Family")) || (history && genres.Contains("History")) ||
                (mystery && genres.Contains("Mystery")) || (scifi && genres.Contains("Sci-Fi")) ||
                (war && genres.Contains("War")) || (adventure && genres.Contains("Adventure")) ||
                (crime && genres.Contains("Crime")) || (fantasy && genres.Contains("Fantasy")) ||
                (horror && genres.Contains("Horror")) || (news && genres.Contains("News")) ||
                (sport && genres.Contains("Sport")) || (western && genres.Contains("Western")) ||
                (animation && genres.Contains("Animation")) || (documentary && genres.Contains("Documentary")) ||
                (filmnoir && genres.Contains("Film-Noir")) || (music && genres.Contains("Music")) ||
                (realitytv && genres.Contains("Reality-TV")) || (talkshow && genres.Contains("Talk-Show")) ||
                (biography && genres.Contains("Biography")) || (drama && genres.Contains("Drama")) ||
                (gameshow && genres.Contains("Game-Show")) ||(musical && genres.Contains("Musical")) ||
                (romance && genres.Contains("Romance")) || (thriller && genres.Contains("Thriller")) )
            {
                match = true;
            }

            return match;
        }
        private bool checkCertification(Movie movie)
        {
            bool match = false;
            string movieCert = movie.certification;

            // If all options are false, accept
            if (!g && !pg && !pg13 && !r && !nc17 && !approved && !noCertification)
            {
                match = true;
            }
            // If one of these is true, accept
            else if ((g && movieCert.Equals("G")) || (pg && movieCert.Equals("PG")) ||
                (pg13 && movieCert.Equals("PG-13")) || (r && movieCert.Equals("R"))
                || (nc17 && movieCert.Equals("NC-17")) || (approved && movieCert.Equals("Approved"))
                || (noCertification && movieCert.Equals("")))
            {
                match = true;
            }

            return match;
        }
        private bool checkActors(Movie movie)
        {
            bool match = false;
            List<string> movieActors = movie.actorList;

            // If all actor fields are empty, accept
            if (noActors())
            {
                match = true;
            }
            // If one actor matches, accept
            else if (matchActor(movieActors) )
            {
                match = true;
            }

            return match;
        }