private void QueryBuilder()
        {
            //Title
            Tuple <string, string> actorName    = ActorBox.Text.ToString().GetTupleFromName();
            Tuple <string, string> directorName = DirectorsBox.Text.ToString().GetTupleFromName();
            Tuple <string, string> writerName   = WritersBox.Text.ToString().GetTupleFromName();

            //string genre = (GenreDropDown.SelectedIndex == -1) ? string.Empty : GenreDropDown.SelectedValue.ToString();
            //List<CheckedListItem> selected = cmb.ItemsSource.Cast<CheckedListItem>().ToList();
            List <string> selectedGenreList   = (selectedGenres == string.Empty) ? new List <string>() : selectedGenres.Split(new[] { ',' }).ToList();
            List <string> selectedRatingsList = (selectedRatings == string.Empty) ? new List <string>() : selectedRatings.Split(new[] { ',' }).ToList();

            Tuple <int, int> length = (LengthDropDown.SelectedIndex == -1)
                                                ? new Tuple <int, int>(0, MovieAppHelpers.GetMaxMovieLength())
                                                : (Tuple <int, int>)LengthDropDown.SelectedValue;

            List <Film> results = (List <Film>)SearchHelpers.RunSearch(paramActorFirst: actorName.Item1, paramActorLast: actorName.Item2,
                                                                       paramRatings: selectedRatingsList, paramGenres: selectedGenreList,
                                                                       paramMin: length.Item1, paramMax: length.Item2,
                                                                       paramDirectorFirst: directorName.Item1, paramDirectorLast: directorName.Item2,
                                                                       paramWriterFirst: writerName.Item1, paramWriterLast: writerName.Item2
                                                                       );

            if (results.Any())
            {
                new Results(results).Switch();
            }
            else
            {
                MessageBox.Show("Your search yielded no results", "No results", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private List <CheckedListItem> FillRatingseDropDown()
        {
            int i = 0;

            return(MovieAppHelpers.GetAllRatings().Select(rating => new CheckedListItem()
            {
                Id = i++,
                IsChecked = false,
                Name = rating
            }).ToList());
        }
        private List <CheckedListItem> FillGenreDropDown()
        {
            int i = 0;

            return(MovieAppHelpers.GetAllGenreNames().Select(genre => new CheckedListItem()
            {
                Id = i++,
                IsChecked = false,
                Name = genre
            }).ToList());
        }
        private void QueryBuilder()
        {
            //Title

            string actorFirst = ActorBox.Text.ToString().Split(' ').FirstOrDefault().Trim();
            string actorLast  = ActorBox.Text.ToString().Split(' ').LastOrDefault().Trim();

            string genre = (GenreDropDown.SelectedIndex == -1) ? string.Empty : GenreDropDown.SelectedValue.ToString();

            string director = (DirectorDropDown.SelectedIndex == -1) ? string.Empty : DirectorDropDown.SelectedValue.ToString();

            string directorFirst = (DirectorDropDown.SelectedIndex == -1) ? string.Empty : DirectorDropDown.SelectedValue.ToString().Split(' ').FirstOrDefault().Trim();
            string directorLast  = (DirectorDropDown.SelectedIndex == -1) ? string.Empty : DirectorDropDown.SelectedValue.ToString().Split(' ').LastOrDefault().Trim();

            Tuple <int, int> length = (LengthDropDown.SelectedIndex == -1)
                                                ? new Tuple <int, int>(0, MovieAppHelpers.GetMaxMovieLength())
                                                : (Tuple <int, int>)LengthDropDown.SelectedValue;

            List <Film> results = SearchHelpers.RunSearch(paramActorFirst: actorFirst, paramActorLast: actorLast, paramGenre: genre,
                                                          paramMin: length.Item1, paramMax: length.Item2,
                                                          paramDirectorFirst: directorFirst, paramDirectorLast: directorLast);

            WPFHelpers.SwitchToNewWindow <Results>(new object[] { results });
        }
Exemple #5
0
 private void SetUpChart()
 {
     genreChart.DataContext = MovieAppHelpers.MoviesByGenre();
     //actorChart.DataContext = MovieAppHelpers.MoviesByActor();
 }
 private IEnumerable FillDirectorDropDown()
 {
     return
         (MovieAppHelpers.GetAllDirectorNames());
 }
 private IEnumerable FillGenreDropDown()
 {
     return(MovieAppHelpers.GetAllGenreNames());
 }
 private IEnumerable FillLengthDropDown()
 {
     return(MovieAppHelpers.GetLengthsInRanges());
 }
        private void ButtonClick1(object sender, RoutedEventArgs e)
        {
            _moviesInsertedSuccessfully = 0;
            MoviesToAdd            = listOfMovies.Text.Split(new[] { "\r\n", "\n", Environment.NewLine }, StringSplitOptions.None).ToList();
            progressBar.Minimum    = 0;
            progressBar.Maximum    = MoviesToAdd.Count;
            progressBar.Value      = 0;
            progressBar.Visibility = Visibility.Visible;

            Stopwatch timer = new Stopwatch();

            timer.Start();
            foreach (string movieToRetrieve in MoviesToAdd)
            {
                _movieCount++;

                if (!string.IsNullOrWhiteSpace(movieToRetrieve))
                {
                    IMDB Movie;
                    if (movieToRetrieve.Contains(@"http://www.imdb.com/title"))
                    {
                        Movie = new IMDB(movieToRetrieve, true);
                        AddMovie(Movie);
                    }
                    else
                    {
                        if (!MovieAppHelpers.CheckDBForMovie(movieToRetrieve))
                        {
                            try
                            {
                                Movie = new IMDB(movieToRetrieve);

                                if (Movie.Title.ToLower() != movieToRetrieve.ToLower())
                                {
                                    string message = string.Format(
                                        "Retrieved title [ {1} ] did not match entered title [ {2} ], add anyway?{0}{0}[ Title: {1}, Year: {3}, Lead: {4} ]",
                                        Environment.NewLine, Movie.Title, movieToRetrieve, Movie.Year ?? string.Empty,
                                        (Movie.Cast != null) ? Movie.Cast.ToArray().FirstOrDefault() : string.Empty);

                                    MessageBoxResult msgBoxResult = MessageBox.Show(message, "Ambiguous Match Found", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.DefaultDesktopOnly);

                                    if (msgBoxResult == MessageBoxResult.Yes)
                                    {
                                        AddMovie(Movie);
                                    }

                                    if (msgBoxResult == MessageBoxResult.No)
                                    {
                                        Log.Trace(
                                            "Retrieved Movie: [ Title: {0}, Year: {1}, Lead: {2} ] Entered Movie: [ Title: {3} ]",
                                            new object[]
                                        {
                                            Movie.Title, Movie.Year ?? string.Empty,
                                            (Movie.Cast != null)
                                                        ? Movie.Cast.ToArray().FirstOrDefault()
                                                        : string.Empty, movieToRetrieve
                                        });
                                        Dispatcher.Invoke(_updatePbDelegate,
                                                          System.Windows.Threading.DispatcherPriority.Background,
                                                          new object[]
                                        {
                                            RangeBase.ValueProperty, (double)_movieCount
                                        });
                                    }
                                }
                                else // Titles Match
                                {
                                    AddMovie(Movie);
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Trace("Could not complete movie retrieval and insert", ex, movieToRetrieve);
                                //Log.Error("Could not complete movie insert, exception: [ {0} ]", ex.ToString());
                            }
                        }
                    }
                }
            }

            //Switcher.Switch(new AddResults( processedMovies));
            timer.Stop();
            "Inserted {0} of {1} movies successfully, Total run time: {2}, (see log for any failures)".ShowMessage(new object[] { _moviesInsertedSuccessfully, MoviesToAdd.Count, timer.Elapsed.ToReadableString() });
        }