public Contract_AniDB_AnimeCrossRefs GetCrossRefDetails(int animeID) { Contract_AniDB_AnimeCrossRefs result = new Contract_AniDB_AnimeCrossRefs(); result.AnimeID = animeID; try { using (var session = JMMService.SessionFactory.OpenSession()) { TvDB_SeriesRepository repSeries = new TvDB_SeriesRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(animeID); if (anime == null) return result; TvDB_ImageFanartRepository repFanart = new TvDB_ImageFanartRepository(); TvDB_ImagePosterRepository repPosters = new TvDB_ImagePosterRepository(); TvDB_ImageWideBannerRepository repBanners = new TvDB_ImageWideBannerRepository(); // TvDB foreach (CrossRef_AniDB_TvDBV2 xref in anime.GetCrossRefTvDBV2()) { result.CrossRef_AniDB_TvDB.Add(xref.ToContract()); TvDB_Series ser = repSeries.GetByTvDBID(session, xref.TvDBID); if (ser != null) result.TvDBSeries.Add(ser.ToContract()); foreach (TvDB_Episode ep in anime.GetTvDBEpisodes()) result.TvDBEpisodes.Add(ep.ToContract()); foreach (TvDB_ImageFanart fanart in repFanart.GetBySeriesID(session, xref.TvDBID)) result.TvDBImageFanarts.Add(fanart.ToContract()); foreach (TvDB_ImagePoster poster in repPosters.GetBySeriesID(session, xref.TvDBID)) result.TvDBImagePosters.Add(poster.ToContract()); foreach (TvDB_ImageWideBanner banner in repBanners.GetBySeriesID(xref.TvDBID)) result.TvDBImageWideBanners.Add(banner.ToContract()); } // Trakt Trakt_ImageFanartRepository repTraktFanart = new Trakt_ImageFanartRepository(); Trakt_ImagePosterRepository repTraktPosters = new Trakt_ImagePosterRepository(); Trakt_ShowRepository repTrakt = new Trakt_ShowRepository(); foreach (CrossRef_AniDB_TraktV2 xref in anime.GetCrossRefTraktV2()) { result.CrossRef_AniDB_Trakt.Add(xref.ToContract()); Trakt_Show show = repTrakt.GetByTraktSlug(session, xref.TraktID); if (show != null) { result.TraktShows.Add(show.ToContract()); foreach (Trakt_ImageFanart fanart in repTraktFanart.GetByShowID(session, show.Trakt_ShowID)) result.TraktImageFanarts.Add(fanart.ToContract()); foreach (Trakt_ImagePoster poster in repTraktPosters.GetByShowID(session, show.Trakt_ShowID)) result.TraktImagePosters.Add(poster.ToContract()); } } // MovieDB CrossRef_AniDB_Other xrefMovie = anime.GetCrossRefMovieDB(); if (xrefMovie == null) result.CrossRef_AniDB_MovieDB = null; else result.CrossRef_AniDB_MovieDB = xrefMovie.ToContract(); MovieDB_Movie movie = anime.GetMovieDBMovie(); if (movie == null) result.MovieDBMovie = null; else result.MovieDBMovie = movie.ToContract(); foreach (MovieDB_Fanart fanart in anime.GetMovieDBFanarts()) { if (fanart.ImageSize.Equals(Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) result.MovieDBFanarts.Add(fanart.ToContract()); } foreach (MovieDB_Poster poster in anime.GetMovieDBPosters()) { if (poster.ImageSize.Equals(Constants.MovieDBImageSize.Original, StringComparison.InvariantCultureIgnoreCase)) result.MovieDBPosters.Add(poster.ToContract()); } // MAL List<CrossRef_AniDB_MAL> xrefMAL = anime.GetCrossRefMAL(); if (xrefMAL == null) result.CrossRef_AniDB_MAL = null; else { result.CrossRef_AniDB_MAL = new List<Contract_CrossRef_AniDB_MAL>(); foreach (CrossRef_AniDB_MAL xrefTemp in xrefMAL) result.CrossRef_AniDB_MAL.Add(xrefTemp.ToContract()); } } return result; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); return result; } }
public static void RemoveTraktDBEntries(Trakt_Show show) { Trakt_ShowRepository repShows = new Trakt_ShowRepository(); CrossRef_AniDB_TraktV2Repository repXRefs = new CrossRef_AniDB_TraktV2Repository(); Trakt_ImageFanartRepository repFanart = new Trakt_ImageFanartRepository(); Trakt_SeasonRepository repSeasons = new Trakt_SeasonRepository(); Trakt_EpisodeRepository repEpisodes = new Trakt_EpisodeRepository(); Trakt_ImagePosterRepository repPosters = new Trakt_ImagePosterRepository(); // this means Trakt has no record of this slug. // 1. Delete any cross ref links foreach (CrossRef_AniDB_TraktV2 xref in repXRefs.GetByTraktID(show.TraktID)) repXRefs.Delete(xref.CrossRef_AniDB_TraktV2ID); // 2. Delete default image links // 3. Delete episodes foreach (Trakt_Episode epTemp in repEpisodes.GetByShowID(show.Trakt_ShowID)) repEpisodes.Delete(epTemp.Trakt_EpisodeID); // 4. Delete fanart and posters foreach (Trakt_ImageFanart fanart in repFanart.GetByShowID(show.Trakt_ShowID)) repFanart.Delete(fanart.Trakt_ImageFanartID); foreach (Trakt_ImagePoster poster in repPosters.GetByShowID(show.Trakt_ShowID)) repPosters.Delete(poster.Trakt_ImagePosterID); // 5. Delete seasons foreach (Trakt_Season season in repSeasons.GetByShowID(show.Trakt_ShowID)) repSeasons.Delete(season.Trakt_SeasonID); // 6. Delete the show repShows.Delete(show.Trakt_ShowID); }
public List<Contract_Trakt_ImagePoster> GetAllTraktPosters(int? traktShowID) { List<Contract_Trakt_ImagePoster> allImages = new List<Contract_Trakt_ImagePoster>(); try { Trakt_ImagePosterRepository repImages = new Trakt_ImagePosterRepository(); List<Trakt_ImagePoster> allPosters = null; if (traktShowID.HasValue) allPosters = repImages.GetByShowID(traktShowID.Value); else allPosters = repImages.GetAll(); foreach (Trakt_ImagePoster img in allPosters) allImages.Add(img.ToContract()); return allImages; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); return allImages; } }