Пример #1
0
        // This function also searches for movies but is used to show them in a more user-friendly manner
        public static DataTable SearchForMovieDisplay(MovieSearchType type, MoviesToShow moviesToShow, string input)
        {
            string sql;

            if (input == "")
            {
                type = MovieSearchType.None;
            }

            if (moviesToShow == MoviesToShow.AllMovies)
            {
                switch (type)
                {
                case MovieSearchType.None:
                {
                    sql = SqlProcedures.RetrieveMoviesDisplay();
                    return(Call(sql));
                }

                case MovieSearchType.MovieTitle:
                {
                    sql = SqlProcedures.GetMoviesByTitleDisplay(input);
                    return(Call(sql));
                }

                case MovieSearchType.MovieGenre:
                {
                    sql = SqlProcedures.GetMoviesByGenreDisplay(input);
                    return(Call(sql));
                }

                case MovieSearchType.MovieDirector:
                {
                    sql = SqlProcedures.GetMoviesByDirectorDisplay(input);
                    return(Call(sql));
                }
                }
            }
            else
            {
                bool isRemoved = (moviesToShow == MoviesToShow.OnlyUnavailable);

                switch (type)
                {
                case MovieSearchType.None:
                {
                    sql = SqlProcedures.GetFilteredMoviesDisplay(isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieTitle:
                {
                    sql = SqlProcedures.GetFilteredMoviesByTitleDisplay(input, isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieGenre:
                {
                    sql = SqlProcedures.GetFilteredMoviesByGenreDisplay(input, isRemoved);
                    return(Call(sql));
                }

                case MovieSearchType.MovieDirector:
                {
                    sql = SqlProcedures.GetFilteredMoviesByDirectorDisplay(input, isRemoved);
                    return(Call(sql));
                }
                }
            }

            return(null);
        }