示例#1
0
        private MovieSearchResult SearchMovie(string title)
        {
            MovieSearchResult result;

            try
            {
                var list = movieDbApi.SearchMovie(title, App.Config.SelectedTMDBLanguageValue);
                if (list.Count == 0)
                {
                    MessageBox.Show("nothing found");
                    return(null);
                }

                int iResult;
                if (list.Count > 1)
                {
                    SearchResult w = new SearchResult();
                    w.SetItemSource(list);
                    w.ShowDialog();
                    iResult = w.SelectedIndex;
                }
                else
                {
                    iResult = 0;
                }

                if (iResult < 0)
                {
                    return(null);
                }

                result = list[iResult];
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message);
                return(null);
            }

            return(result);
        }
 /// <summary>
 /// Search for Movie by name.
 /// </summary>
 /// <param name="movieName">Name</param>
 /// <param name="language">Language, if <c>null</c> it takes the <see cref="PreferredLanguage"/></param>
 /// <param name="movies">Returns the list of matches.</param>
 /// <returns><c>true</c> if at least one Movie was found.</returns>
 public bool SearchMovie(string movieName, string language, out List <MovieSearchResult> movies)
 {
     movies = _movieDbHandler.SearchMovie(movieName, language);
     return(movies.Count > 0);
 }