Ejemplo n.º 1
0
        public Movie(DM.MovieApi.MovieDb.Movies.Movie movie, DM.MovieApi.MovieDb.Movies.MovieCredit credit)
        {
            Id            = movie.Id;
            Title         = movie.Title;
            IsAdultThemed = movie.IsAdultThemed;
            BackdropPath  = movie.BackdropPath;
            OriginalTitle = movie.OriginalTitle;
            Runtime       = movie.Runtime;
            Overview      = movie.Overview;
            ReleaseDate   = movie.ReleaseDate;
            Year          = ReleaseDate.Year;
            Poster        = movie.PosterPath;
            Path          = "";
            Popularity    = movie.Popularity;
            VoteAverage   = movie.VoteAverage;
            VoteCount     = movie.VoteCount;

            Genres = new List <Genre>();
            foreach (DM.MovieApi.MovieDb.Genres.Genre element in movie.Genres)
            {
                Genres.Add(new Genre(element));
            }

            Directors = new List <Director>();
            foreach (DM.MovieApi.MovieDb.Movies.MovieCrewMember element in credit.CrewMembers)
            {
                if (element.Job == "Director")
                {
                    Directors.Add(new Director(element));
                }
            }

            Writers = new List <Writer>();
            foreach (DM.MovieApi.MovieDb.Movies.MovieCrewMember element in credit.CrewMembers)
            {
                if (element.Department == "Writing")
                {
                    Writers.Add(new Writer(element));
                }
            }

            Actors = new List <Actor>();
            long iter = 0;

            foreach (DM.MovieApi.MovieDb.Movies.MovieCastMember element in credit.CastMembers)
            {
                if (iter >= 20)
                {
                    break;
                }
                Actors.Add(new Actor(element));
                iter++;
            }
        }
Ejemplo n.º 2
0
        private async Task LoadMovies(ApiSearchResponse <MovieInfo> responseMovieInfos)
        {
            this._movies = new List <Movie>();
            var movieApi = MovieDbFactory.Create <IApiMovieRequest>().Value;

            int runtime = 0;

            if (responseMovieInfos != null && responseMovieInfos.Results != null && responseMovieInfos.Results.Count != 0)
            {
                foreach (MovieInfo info in responseMovieInfos.Results)
                {
                    // Get movie id
                    int movieId = info.Id;

                    // Get Movie object - to get runtime
                    ApiQueryResponse <DM.MovieApi.MovieDb.Movies.Movie> responseMovies = await movieApi.FindByIdAsync(movieId);

                    DM.MovieApi.MovieDb.Movies.Movie movie = responseMovies.Item;
                    if (movie != null)
                    {
                        runtime = movie.Runtime;
                    }

                    // Get MovieCredit object - to get list of actors
                    ApiQueryResponse <MovieCredit> responseCredits = await movieApi.GetCreditsAsync(movieId);

                    MovieCredit credit = responseCredits.Item;

                    string actors = "";
                    // Take first 3 actors
                    if (credit != null && credit.CastMembers != null && credit.CastMembers.Count != 0)
                    {
                        int actorsListSize = credit.CastMembers.Count > 3 ? 3 : credit.CastMembers.Count;
                        for (int i = 0; i < actorsListSize; i++)
                        {
                            actors += credit.CastMembers[i].Name;
                            if (i != actorsListSize - 1)
                            {
                                actors += ", ";
                            }
                        }
                    }

                    // Put genre to list
                    string genres = "";
                    for (int i = 0; i < info.Genres.Count; i++)
                    {
                        genres += info.Genres[i].Name;
                        if (i != info.Genres.Count - 1)
                        {
                            genres += ", ";
                        }
                    }

                    string title      = info.Title == null ? "" : info.Title;
                    string year       = info.ReleaseDate.Year.ToString() == null ? "" : info.ReleaseDate.Year.ToString();
                    string overview   = info.Overview == null ? "" : info.Overview;
                    string posterPath = info.PosterPath;
                    this.AddMovie(title, year, overview, posterPath, actors, genres, runtime);
                }
            }
        }