public void Fill(VM_AniDB_Anime anime)
        {
            AllFanarts = new List <FanartContainer>();
            AllPosters = new List <PosterContainer>();

            /*
             * foreach (VM_Trakt_ImageFanart contract in TraktImageFanarts)
             * {
             *  contract.IsImageDefault = anime?.DefaultImageFanart != null && anime.DefaultImageFanart.ImageParentType == (int) ImageEntityType.Trakt_Fanart && anime.DefaultImageFanart.ImageParentID == contract.Trakt_ImageFanartID;
             *  AllFanarts.Add(new FanartContainer(ImageEntityType.Trakt_Fanart, contract));
             * }
             * foreach (VM_Trakt_ImagePoster contract in TraktImagePosters)
             * {
             *  contract.IsImageDefault = anime?.DefaultImagePoster != null && anime.DefaultImagePoster.ImageParentType == (int) ImageEntityType.Trakt_Poster && anime.DefaultImagePoster.ImageParentID == contract.Trakt_ImagePosterID;
             *  AllPosters.Add(new PosterContainer(ImageEntityType.Trakt_Poster, contract));
             * }*/
            if (TvDBImageFanarts != null)
            {
                foreach (VM_TvDB_ImageFanart contract in TvDBImageFanarts.CastList <VM_TvDB_ImageFanart>())
                {
                    contract.IsImageDefault = anime?.DefaultImageFanart != null && anime.DefaultImageFanart.ImageParentType == (int)ImageEntityType.TvDB_FanArt && anime.DefaultImageFanart.ImageParentID == contract.TvDB_ImageFanartID;
                    AllFanarts.Add(new FanartContainer(ImageEntityType.TvDB_FanArt, contract));
                }
            }
            if (TvDBImagePosters != null)
            {
                foreach (VM_TvDB_ImagePoster contract in TvDBImagePosters.CastList <VM_TvDB_ImagePoster>())
                {
                    contract.IsImageDefault = anime?.DefaultImagePoster != null && anime.DefaultImagePoster.ImageParentType == (int)ImageEntityType.TvDB_Cover && anime.DefaultImagePoster.ImageParentID == contract.TvDB_ImagePosterID;
                    AllPosters.Add(new PosterContainer(ImageEntityType.TvDB_Cover, contract));
                }
            }
            if (TvDBImageWideBanners != null)
            {
                foreach (VM_TvDB_ImageWideBanner contract in TvDBImageWideBanners.CastList <VM_TvDB_ImageWideBanner>())
                {
                    contract.IsImageDefault = anime?.DefaultImageWideBanner != null && anime.DefaultImageWideBanner.ImageParentType == (int)ImageEntityType.TvDB_Banner && anime.DefaultImageWideBanner.ImageParentID == contract.TvDB_ImageWideBannerID;
                }
            }
            if (MovieDBFanarts != null)
            {
                foreach (VM_MovieDB_Fanart contract in MovieDBFanarts.CastList <VM_MovieDB_Fanart>())
                {
                    contract.IsImageDefault = anime?.DefaultImageFanart != null && anime.DefaultImageFanart.ImageParentType == (int)ImageEntityType.MovieDB_FanArt && anime.DefaultImageFanart.ImageParentID == contract.MovieDB_FanartID;
                    AllFanarts.Add(new FanartContainer(ImageEntityType.MovieDB_FanArt, contract));
                }
            }
            if (MovieDBPosters != null)
            {
                foreach (VM_MovieDB_Poster contract in MovieDBPosters.CastList <VM_MovieDB_Poster>())
                {
                    contract.IsImageDefault = anime?.DefaultImagePoster != null && anime.DefaultImagePoster.ImageParentType == (int)ImageEntityType.MovieDB_Poster && anime.DefaultImagePoster.ImageParentID == contract.MovieDB_PosterID;
                    AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, contract));
                }
            }
            BaseConfig.MyAnimeLog.Write("Fill: Posters: " + AllPosters.Count + " Fanarts: " + AllFanarts.Count);
        }
Exemplo n.º 2
0
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeCrossRefs details)
        {
            AnimeID = details.AnimeID;

            AniDB_AnimeVM anime = JMMServerHelper.GetAnime(AnimeID);

            if (anime == null)
            {
                return;
            }



            // Trakt
            if (details.CrossRef_AniDB_Trakt != null)
            {
                CrossRef_AniDB_Trakt = new CrossRef_AniDB_TraktVM(details.CrossRef_AniDB_Trakt);
            }

            if (details.TraktShow != null)
            {
                TraktShow = new Trakt_ShowVM(details.TraktShow);
            }

            if (details.TraktImageFanart != null)
            {
                TraktImageFanart = new Trakt_ImageFanartVM(details.TraktImageFanart);

                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.Trakt_Fanart &&
                    anime.DefaultFanart.ImageParentID == TraktImageFanart.Trakt_ImageFanartID)
                {
                    isDefault = true;
                }

                TraktImageFanart.IsImageDefault = isDefault;

                AllFanarts.Add(new FanartContainer(ImageEntityType.Trakt_Fanart, TraktImageFanart));
            }

            if (details.TraktImagePoster != null)
            {
                TraktImagePoster = new Trakt_ImagePosterVM(details.TraktImagePoster);

                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.Trakt_Poster &&
                    anime.DefaultPoster.ImageParentID == TraktImagePoster.Trakt_ImagePosterID)
                {
                    isDefault = true;
                }

                TraktImagePoster.IsImageDefault = isDefault;

                AllPosters.Add(new PosterContainer(ImageEntityType.Trakt_Poster, TraktImagePoster));
            }

            if (CrossRef_AniDB_Trakt == null || TraktShow == null)
            {
                TraktCrossRefExists = false;
            }
            else
            {
                TraktCrossRefExists = true;
            }

            // TvDB
            if (details.CrossRef_AniDB_TvDB != null)
            {
                CrossRef_AniDB_TvDB = new List <CrossRef_AniDB_TvDBVMV2>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TvDBV2 contract in details.CrossRef_AniDB_TvDB)
                {
                    CrossRef_AniDB_TvDBVMV2 xref = new CrossRef_AniDB_TvDBVMV2(contract);
                    CrossRef_AniDB_TvDB.Add(xref);
                }
            }

            if (details.TvDBSeries != null)
            {
                TvDBSeries = new List <TvDB_SeriesVM>();
                foreach (JMMServerBinary.Contract_TvDB_Series contract in details.TvDBSeries)
                {
                    TvDB_SeriesVM tv = new TvDB_SeriesVM(contract);
                    TvDBSeries.Add(tv);
                }
            }

            foreach (JMMServerBinary.Contract_TvDB_Episode contract in details.TvDBEpisodes)
            {
                TvDBEpisodes.Add(new TvDB_EpisodeVM(contract));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImageFanart contract in details.TvDBImageFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.TvDB_FanArt &&
                    anime.DefaultFanart.ImageParentID == contract.TvDB_ImageFanartID)
                {
                    isDefault = true;
                }

                TvDB_ImageFanartVM tvFanart = new TvDB_ImageFanartVM(contract);
                tvFanart.IsImageDefault = isDefault;
                TvDBImageFanarts.Add(tvFanart);

                AllFanarts.Add(new FanartContainer(ImageEntityType.TvDB_FanArt, tvFanart));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImagePoster contract in details.TvDBImagePosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.TvDB_Cover &&
                    anime.DefaultPoster.ImageParentID == contract.TvDB_ImagePosterID)
                {
                    isDefault = true;
                }

                TvDB_ImagePosterVM tvPoster = new TvDB_ImagePosterVM(contract);
                tvPoster.IsImageDefault = isDefault;
                TvDBImagePosters.Add(tvPoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.TvDB_Cover, tvPoster));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImageWideBanner contract in details.TvDBImageWideBanners)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultWideBanner != null && anime.DefaultWideBanner.ImageParentType == (int)ImageEntityType.TvDB_Banner &&
                    anime.DefaultWideBanner.ImageParentID == contract.TvDB_ImageWideBannerID)
                {
                    isDefault = true;
                }

                TvDB_ImageWideBannerVM tvBanner = new TvDB_ImageWideBannerVM(contract);
                tvBanner.IsImageDefault = isDefault;
                TvDBImageWideBanners.Add(tvBanner);
            }

            if ((CrossRef_AniDB_TvDB == null || CrossRef_AniDB_TvDB.Count == 0) ||
                (TvDBSeries == null || TvDBSeries.Count == 0))
            {
                TvDBCrossRefExists = false;
            }
            else
            {
                TvDBCrossRefExists = true;
            }

            // MovieDB
            if (details.CrossRef_AniDB_MovieDB != null)
            {
                CrossRef_AniDB_MovieDB = new CrossRef_AniDB_OtherVM(details.CrossRef_AniDB_MovieDB);
            }

            if (details.MovieDBMovie != null)
            {
                MovieDB_Movie = new MovieDB_MovieVM(details.MovieDBMovie);
            }

            foreach (JMMServerBinary.Contract_MovieDB_Fanart contract in details.MovieDBFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.MovieDB_FanArt &&
                    anime.DefaultFanart.ImageParentID == contract.MovieDB_FanartID)
                {
                    isDefault = true;
                }

                MovieDB_FanartVM movieFanart = new MovieDB_FanartVM(contract);
                movieFanart.IsImageDefault = isDefault;
                MovieDBFanarts.Add(movieFanart);
                AllFanarts.Add(new FanartContainer(ImageEntityType.MovieDB_FanArt, movieFanart));
            }

            foreach (JMMServerBinary.Contract_MovieDB_Poster contract in details.MovieDBPosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.MovieDB_Poster &&
                    anime.DefaultPoster.ImageParentID == contract.MovieDB_PosterID)
                {
                    isDefault = true;
                }

                MovieDB_PosterVM moviePoster = new MovieDB_PosterVM(contract);
                moviePoster.IsImageDefault = isDefault;
                MovieDBPosters.Add(moviePoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, moviePoster));
            }

            if (CrossRef_AniDB_MovieDB == null || MovieDB_Movie == null)
            {
                MovieDBCrossRefExists = false;
            }
            else
            {
                MovieDBCrossRefExists = true;
            }
        }