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 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 }); }