예제 #1
0
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeCrossRefs details)
        {
            AnimeID = details.AnimeID;

            CrossRef_AniDB_TvDBV2 = new ObservableCollection <CrossRef_AniDB_TvDBVMV2>();
            TvDBSeriesV2          = new List <TvDB_SeriesVM>();
            TvDBEpisodes          = new List <TvDB_EpisodeVM>();
            TvDBImageFanarts      = new List <TvDB_ImageFanartVM>();
            TvDBImagePosters      = new List <TvDB_ImagePosterVM>();
            TvDBImageWideBanners  = new List <TvDB_ImageWideBannerVM>();

            CrossRef_AniDB_MovieDB = null;
            MovieDB_Movie          = null;
            MovieDBPosters         = new List <MovieDB_PosterVM>();
            MovieDBFanarts         = new List <MovieDB_FanartVM>();

            CrossRef_AniDB_TraktV2 = new ObservableCollection <CrossRef_AniDB_TraktVMV2>();
            TraktShowV2            = new List <Trakt_ShowVM>();
            TraktImageFanarts      = new List <Trakt_ImageFanartVM>();
            TraktImagePosters      = new List <Trakt_ImagePosterVM>();

            CrossRef_AniDB_MAL = new ObservableCollection <CrossRef_AniDB_MALVM>();

            AllPosters = new List <PosterContainer>();
            AllFanarts = new List <FanartContainer>();

            /*CrossRef_AniDB_TvDBV2.Clear();
             * TvDBSeriesV2.Clear();
             * TvDBEpisodes.Clear();
             * TvDBImageFanarts.Clear();
             * TvDBImagePosters.Clear();
             * TvDBImageWideBanners.Clear();
             *
             * CrossRef_AniDB_MovieDB = null;
             * MovieDB_Movie = null;
             * MovieDBPosters.Clear();
             * MovieDBFanarts.Clear();
             *
             * CrossRef_AniDB_TraktV2.Clear();
             * TraktShowV2.Clear();
             * TraktImageFanarts.Clear();
             * TraktImagePosters.Clear();
             *
             * CrossRef_AniDB_MAL = null;
             *
             * AllPosters.Clear();
             * AllFanarts.Clear();*/

            AniDB_AnimeVM anime = null;

            if (MainListHelperVM.Instance.AllAnimeDictionary.ContainsKey(AnimeID))
            {
                anime = MainListHelperVM.Instance.AllAnimeDictionary[AnimeID];
            }

            //AniDB
            AllPosters.Insert(0, new PosterContainer(ImageEntityType.AniDB_Cover, anime));


            // MAL
            if (details.CrossRef_AniDB_MAL != null)
            {
                CrossRef_AniDB_MAL = new ObservableCollection <CrossRef_AniDB_MALVM>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_MAL contract in details.CrossRef_AniDB_MAL)
                {
                    CrossRef_AniDB_MAL.Add(new CrossRef_AniDB_MALVM(contract));
                }
            }

            if (CrossRef_AniDB_MAL == null || CrossRef_AniDB_MAL.Count == 0)
            {
                MALCrossRefExists  = false;
                MALCrossRefMissing = true;
            }
            else
            {
                MALCrossRefExists  = true;
                MALCrossRefMissing = false;
            }

            // Trakt
            if (details.CrossRef_AniDB_Trakt != null)
            {
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TraktV2 contract in details.CrossRef_AniDB_Trakt)
                {
                    CrossRef_AniDB_TraktV2.Add(new CrossRef_AniDB_TraktVMV2(contract));
                }
            }

            if (details.TraktShows != null)
            {
                foreach (JMMServerBinary.Contract_Trakt_Show contract in details.TraktShows)
                {
                    TraktShowV2.Add(new Trakt_ShowVM(contract));
                }
            }

            foreach (JMMServerBinary.Contract_Trakt_ImageFanart contract in details.TraktImageFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.Trakt_Fanart &&
                    anime.DefaultFanart.ImageParentID == contract.Trakt_ImageFanartID)
                {
                    isDefault = true;
                }

                Trakt_ImageFanartVM traktFanart = new Trakt_ImageFanartVM(contract);
                traktFanart.IsImageDefault    = isDefault;
                traktFanart.IsImageNotDefault = !isDefault;
                TraktImageFanarts.Add(traktFanart);

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

            foreach (JMMServerBinary.Contract_Trakt_ImagePoster contract in details.TraktImagePosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.Trakt_Poster &&
                    anime.DefaultPoster.ImageParentID == contract.Trakt_ImagePosterID)
                {
                    isDefault = true;
                }

                Trakt_ImagePosterVM traktPoster = new Trakt_ImagePosterVM(contract);
                traktPoster.IsImageDefault    = isDefault;
                traktPoster.IsImageNotDefault = !isDefault;
                TraktImagePosters.Add(traktPoster);

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

            if (CrossRef_AniDB_TraktV2 == null || CrossRef_AniDB_TraktV2.Count == 0 || TraktShowV2 == null || TraktShowV2.Count == 0)
            {
                TraktCrossRefExists  = false;
                TraktCrossRefMissing = true;
            }
            else
            {
                TraktCrossRefExists  = true;
                TraktCrossRefMissing = false;
            }

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

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

            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;
                tvFanart.IsImageNotDefault = !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;
                tvPoster.IsImageNotDefault = !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;
                tvBanner.IsImageNotDefault = !isDefault;
                TvDBImageWideBanners.Add(tvBanner);
            }

            if (CrossRef_AniDB_TvDBV2.Count == 0 || TvDBSeriesV2.Count == 0)
            {
                TvDBCrossRefExists  = false;
                TvDBCrossRefMissing = true;
            }
            else
            {
                TvDBCrossRefExists  = true;
                TvDBCrossRefMissing = false;
            }

            // 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;
                movieFanart.IsImageNotDefault = !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;
                moviePoster.IsImageNotDefault = !isDefault;
                MovieDBPosters.Add(moviePoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, moviePoster));
            }

            if (CrossRef_AniDB_MovieDB == null || MovieDB_Movie == null)
            {
                MovieDBCrossRefExists  = false;
                MovieDBCrossRefMissing = true;
            }
            else
            {
                MovieDBCrossRefExists  = true;
                MovieDBCrossRefMissing = false;
            }
        }
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeCrossRefs details)
        {
            AnimeID = details.AnimeID;

            CrossRef_AniDB_TvDBV2 = new ObservableCollection<CrossRef_AniDB_TvDBVMV2>();
            TvDBSeriesV2 = new List<TvDB_SeriesVM>();
            TvDBEpisodes = new List<TvDB_EpisodeVM>();
            TvDBImageFanarts = new List<TvDB_ImageFanartVM>();
            TvDBImagePosters = new List<TvDB_ImagePosterVM>();
            TvDBImageWideBanners = new List<TvDB_ImageWideBannerVM>();

            CrossRef_AniDB_MovieDB = null;
            MovieDB_Movie = null;
            MovieDBPosters = new List<MovieDB_PosterVM>();
            MovieDBFanarts = new List<MovieDB_FanartVM>();

            CrossRef_AniDB_TraktV2 = new ObservableCollection<CrossRef_AniDB_TraktVMV2>();
            TraktShowV2 = new List<Trakt_ShowVM>();
            TraktImageFanarts = new List<Trakt_ImageFanartVM>();
            TraktImagePosters = new List<Trakt_ImagePosterVM>();

            CrossRef_AniDB_MAL = new ObservableCollection<CrossRef_AniDB_MALVM>();

            AllPosters = new List<PosterContainer>();
            AllFanarts = new List<FanartContainer>();

            /*CrossRef_AniDB_TvDBV2.Clear();
            TvDBSeriesV2.Clear();
            TvDBEpisodes.Clear();
            TvDBImageFanarts.Clear();
            TvDBImagePosters.Clear();
            TvDBImageWideBanners.Clear();

            CrossRef_AniDB_MovieDB = null;
            MovieDB_Movie = null;
            MovieDBPosters.Clear();
            MovieDBFanarts.Clear();

            CrossRef_AniDB_TraktV2.Clear();
            TraktShowV2.Clear();
            TraktImageFanarts.Clear();
            TraktImagePosters.Clear();

            CrossRef_AniDB_MAL = null;

            AllPosters.Clear();
            AllFanarts.Clear();*/

            AniDB_AnimeVM anime = null;
            if (MainListHelperVM.Instance.AllAnimeDictionary.ContainsKey(AnimeID))
                anime = MainListHelperVM.Instance.AllAnimeDictionary[AnimeID];

            //AniDB
            AllPosters.Insert(0, new PosterContainer(ImageEntityType.AniDB_Cover, anime));

            // MAL
            if (details.CrossRef_AniDB_MAL != null)
            {
                CrossRef_AniDB_MAL = new ObservableCollection<CrossRef_AniDB_MALVM>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_MAL contract in details.CrossRef_AniDB_MAL)
                    CrossRef_AniDB_MAL.Add(new CrossRef_AniDB_MALVM(contract));
            }

            if (CrossRef_AniDB_MAL == null || CrossRef_AniDB_MAL.Count == 0)
            {
                MALCrossRefExists = false;
                MALCrossRefMissing = true;
            }
            else
            {
                MALCrossRefExists = true;
                MALCrossRefMissing = false;
            }

            // Trakt
            if (details.CrossRef_AniDB_Trakt != null)
            {
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TraktV2 contract in details.CrossRef_AniDB_Trakt)
                    CrossRef_AniDB_TraktV2.Add(new CrossRef_AniDB_TraktVMV2(contract));
            }

            if (details.TraktShows != null)
            {
                foreach (JMMServerBinary.Contract_Trakt_Show contract in details.TraktShows)
                    TraktShowV2.Add(new Trakt_ShowVM(contract));
            }

            foreach (JMMServerBinary.Contract_Trakt_ImageFanart contract in details.TraktImageFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.Trakt_Fanart
                    && anime.DefaultFanart.ImageParentID == contract.Trakt_ImageFanartID)
                {
                    isDefault = true;
                }

                Trakt_ImageFanartVM traktFanart = new Trakt_ImageFanartVM(contract);
                traktFanart.IsImageDefault = isDefault;
                traktFanart.IsImageNotDefault = !isDefault;
                TraktImageFanarts.Add(traktFanart);

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

            foreach (JMMServerBinary.Contract_Trakt_ImagePoster contract in details.TraktImagePosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.Trakt_Poster
                    && anime.DefaultPoster.ImageParentID == contract.Trakt_ImagePosterID)
                {
                    isDefault = true;
                }

                Trakt_ImagePosterVM traktPoster = new Trakt_ImagePosterVM(contract);
                traktPoster.IsImageDefault = isDefault;
                traktPoster.IsImageNotDefault = !isDefault;
                TraktImagePosters.Add(traktPoster);

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

            if (CrossRef_AniDB_TraktV2 == null || CrossRef_AniDB_TraktV2.Count == 0 || TraktShowV2 == null || TraktShowV2.Count == 0)
            {
                TraktCrossRefExists = false;
                TraktCrossRefMissing = true;
            }
            else
            {
                TraktCrossRefExists = true;
                TraktCrossRefMissing = false;
            }

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

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

            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;
                tvFanart.IsImageNotDefault = !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;
                tvPoster.IsImageNotDefault = !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;
                tvBanner.IsImageNotDefault = !isDefault;
                TvDBImageWideBanners.Add(tvBanner);
            }

            if (CrossRef_AniDB_TvDBV2.Count == 0 || TvDBSeriesV2.Count == 0)
            {
                TvDBCrossRefExists = false;
                TvDBCrossRefMissing = true;
            }
            else
            {
                TvDBCrossRefExists = true;
                TvDBCrossRefMissing = false;
            }

            // 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;
                movieFanart.IsImageNotDefault = !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;
                moviePoster.IsImageNotDefault = !isDefault;
                MovieDBPosters.Add(moviePoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, moviePoster));
            }

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