public Contract_IgnoreAnime ToContract() { Contract_IgnoreAnime contract = new Contract_IgnoreAnime(); contract.IgnoreAnimeID = this.IgnoreAnimeID; contract.JMMUserID = this.JMMUserID; contract.AnimeID = this.AnimeID; contract.IgnoreType = this.IgnoreType; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID); if (anime != null) { contract.Anime = anime.ToContract(); } return(contract); }
public Contract_BookmarkedAnime ToContract() { Contract_BookmarkedAnime contract = new Contract_BookmarkedAnime(); contract.BookmarkedAnimeID = BookmarkedAnimeID; contract.AnimeID = AnimeID; contract.Priority = Priority; contract.Notes = Notes; contract.Downloading = Downloading; contract.Anime = null; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime an = repAnime.GetByAnimeID(AnimeID); if (an != null) { contract.Anime = an.ToContract(true, null); } return(contract); }
public Contract_AniDB_Anime_Relation ToContract(AniDB_Anime anime, AnimeSeries ser, int userID) { Contract_AniDB_Anime_Relation contract = new Contract_AniDB_Anime_Relation(); contract.AniDB_Anime_RelationID = this.AniDB_Anime_RelationID; contract.AnimeID = this.AnimeID; contract.RelationType = this.RelationType; contract.RelatedAnimeID = this.RelatedAnimeID; contract.AniDB_Anime = null; if (anime != null) { contract.AniDB_Anime = anime.ToContract(); } contract.AnimeSeries = null; if (ser != null) { contract.AnimeSeries = ser.ToContract(ser.GetUserRecord(userID)); } return(contract); }
public Contract_AniDB_Anime_Similar ToContract(AniDB_Anime anime, AnimeSeries ser, int userID) { Contract_AniDB_Anime_Similar contract = new Contract_AniDB_Anime_Similar(); contract.AniDB_Anime_SimilarID = this.AniDB_Anime_SimilarID; contract.AnimeID = this.AnimeID; contract.SimilarAnimeID = this.SimilarAnimeID; contract.Approval = this.Approval; contract.Total = this.Total; contract.AniDB_Anime = null; if (anime != null) { contract.AniDB_Anime = anime.ToContract(); } contract.AnimeSeries = null; if (ser != null) { contract.AnimeSeries = ser.ToContract(ser.GetUserRecord(userID)); } return(contract); }
public Contract_AnimeSeries ToContract(AniDB_Anime animeRec, List <CrossRef_AniDB_TvDBV2> tvDBCrossRefs, CrossRef_AniDB_Other movieDBCrossRef, AnimeSeries_User userRecord, List <TvDB_Series> tvseries, List <CrossRef_AniDB_MAL> malDBCrossRef, bool passedDefaultImages, AniDB_Anime_DefaultImage defPoster, AniDB_Anime_DefaultImage defFanart, AniDB_Anime_DefaultImage defWideBanner, List <AniDB_Anime_Title> titles, bool forceimages = false) { Contract_AnimeSeries contract = new Contract_AnimeSeries(); contract.AniDB_ID = this.AniDB_ID; contract.AnimeGroupID = this.AnimeGroupID; contract.AnimeSeriesID = this.AnimeSeriesID; contract.DateTimeUpdated = this.DateTimeUpdated; contract.DateTimeCreated = this.DateTimeCreated; contract.DefaultAudioLanguage = this.DefaultAudioLanguage; contract.DefaultSubtitleLanguage = this.DefaultSubtitleLanguage; contract.LatestLocalEpisodeNumber = this.LatestLocalEpisodeNumber; contract.EpisodeAddedDate = this.EpisodeAddedDate; contract.MissingEpisodeCount = this.MissingEpisodeCount; contract.MissingEpisodeCountGroups = this.MissingEpisodeCountGroups; contract.SeriesNameOverride = this.SeriesNameOverride; if (userRecord == null) { contract.PlayedCount = 0; contract.StoppedCount = 0; contract.UnwatchedEpisodeCount = 0; contract.WatchedCount = 0; contract.WatchedDate = null; contract.WatchedEpisodeCount = 0; } else { contract.PlayedCount = userRecord.PlayedCount; contract.StoppedCount = userRecord.StoppedCount; contract.UnwatchedEpisodeCount = userRecord.UnwatchedEpisodeCount; contract.WatchedCount = userRecord.WatchedCount; contract.WatchedDate = userRecord.WatchedDate; contract.WatchedEpisodeCount = userRecord.WatchedEpisodeCount; } // get AniDB data contract.AniDBAnime = null; if (animeRec != null) { Contract_AniDBAnime animecontract = animeRec.ToContract(false, titles); AniDB_Anime_DefaultImage defaultPoster = null; if (passedDefaultImages) { defaultPoster = defPoster; } else { defaultPoster = animeRec.GetDefaultPoster(); } if (defaultPoster == null) { animecontract.DefaultImagePoster = null; } else { animecontract.DefaultImagePoster = defaultPoster.ToContract(); } if ((animecontract.DefaultImagePoster == null) && (forceimages)) { ImageDetails im = animeRec.GetDefaultPosterDetailsNoBlanks(); if (im != null) { animecontract.DefaultImagePoster = new Contract_AniDB_Anime_DefaultImage(); animecontract.DefaultImagePoster.AnimeID = im.ImageID; animecontract.DefaultImagePoster.ImageType = (int)im.ImageType; } } AniDB_Anime_DefaultImage defaultFanart = null; if (passedDefaultImages) { defaultFanart = defFanart; } else { defaultFanart = animeRec.GetDefaultFanart(); } if (defaultFanart == null) { animecontract.DefaultImageFanart = null; } else { animecontract.DefaultImageFanart = defaultFanart.ToContract(); } if ((animecontract.DefaultImagePoster == null) && (forceimages)) { ImageDetails im = animeRec.GetDefaultFanartDetailsNoBlanks(); if (im != null) { animecontract.DefaultImageFanart = new Contract_AniDB_Anime_DefaultImage(); animecontract.DefaultImageFanart.AnimeID = im.ImageID; animecontract.DefaultImageFanart.ImageType = (int)im.ImageType; } } AniDB_Anime_DefaultImage defaultWideBanner = null; if (passedDefaultImages) { defaultWideBanner = defWideBanner; } else { defaultWideBanner = animeRec.GetDefaultWideBanner(); } if (defaultWideBanner == null) { animecontract.DefaultImageWideBanner = null; } else { animecontract.DefaultImageWideBanner = defaultWideBanner.ToContract(); } contract.AniDBAnime = animecontract; } contract.CrossRefAniDBTvDBV2 = new List <Contract_CrossRef_AniDB_TvDBV2>(); foreach (CrossRef_AniDB_TvDBV2 tvXref in tvDBCrossRefs) { contract.CrossRefAniDBTvDBV2.Add(tvXref.ToContract()); } contract.TvDB_Series = new List <Contract_TvDB_Series>(); foreach (TvDB_Series ser in tvseries) { contract.TvDB_Series.Add(ser.ToContract()); } contract.CrossRefAniDBMovieDB = null; if (movieDBCrossRef != null) { contract.CrossRefAniDBMovieDB = movieDBCrossRef.ToContract(); } contract.CrossRefAniDBMAL = new List <Contract_CrossRef_AniDB_MAL>(); if (malDBCrossRef != null) { foreach (CrossRef_AniDB_MAL xref in malDBCrossRef) { contract.CrossRefAniDBMAL.Add(xref.ToContract()); } } return(contract); }
public Contract_Trakt_Friend ToContract() { CrossRef_AniDB_TraktRepository repXrefTrakt = new CrossRef_AniDB_TraktRepository(); CrossRef_AniDB_TvDBRepository repXrefTvDB = new CrossRef_AniDB_TvDBRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); Trakt_FriendRepository repFriends = new Trakt_FriendRepository(); Trakt_EpisodeRepository repEpisodes = new Trakt_EpisodeRepository(); Trakt_Friend traktFriend = repFriends.GetByUsername(username); if (traktFriend == null) { return(null); } Contract_Trakt_Friend contract = new Contract_Trakt_Friend(); contract.Trakt_FriendID = traktFriend.Trakt_FriendID; contract.Username = username; contract.Full_name = full_name; contract.Gender = gender; contract.Age = age; contract.Location = location; contract.About = about; contract.Joined = joined; contract.Avatar = avatar; contract.Url = url; contract.JoinedDate = Utils.GetAniDBDateAsDate(joined); contract.WatchedEpisodes = new List <Contract_Trakt_WatchedEpisode>(); // we only care about the watched episodes foreach (TraktTVWatched wtch in watched) { if (wtch.episode != null) { Contract_Trakt_WatchedEpisode watchedEp = new Contract_Trakt_WatchedEpisode(); watchedEp.Watched = wtch.watched; watchedEp.WatchedDate = Utils.GetAniDBDateAsDate(wtch.watched); if (!contract.LastEpisodeWatched.HasValue) { contract.LastEpisodeWatched = watchedEp.WatchedDate; } if (watchedEp.WatchedDate.HasValue && watchedEp.WatchedDate > contract.LastEpisodeWatched) { contract.LastEpisodeWatched = watchedEp.WatchedDate; } watchedEp.AnimeSeriesID = null; watchedEp.Episode_Number = wtch.episode.number; watchedEp.Episode_Overview = wtch.episode.overview; watchedEp.Episode_Season = wtch.episode.season; watchedEp.Episode_Title = wtch.episode.title; watchedEp.Episode_Url = wtch.episode.url; if (wtch.episode.images != null) { watchedEp.Episode_Screenshot = wtch.episode.images.screen; } if (wtch.show != null) { watchedEp.TraktShow = wtch.show.ToContract(); // find the anime and series based on the trakt id int?animeID = null; CrossRef_AniDB_Trakt xref = repXrefTrakt.GetByTraktID(wtch.show.TraktID, int.Parse(wtch.episode.season)); if (xref != null) { animeID = xref.AnimeID; } else { // try the tvdb id instead //TODO /* * CrossRef_AniDB_TvDB xrefTvDB = repXrefTvDB.GetByTvDBID(int.Parse(wtch.show.tvdb_id), int.Parse(wtch.episode.season)); * if (xrefTvDB != null) * animeID = xrefTvDB.AnimeID;*/ } if (animeID.HasValue) { AnimeSeries ser = repSeries.GetByAnimeID(animeID.Value); if (ser != null) { watchedEp.AnimeSeriesID = ser.AnimeSeriesID; } AniDB_Anime anime = repAnime.GetByAnimeID(animeID.Value); if (anime != null) { watchedEp.Anime = anime.ToContract(true, null); } } } contract.WatchedEpisodes.Add(watchedEp); break; // only show the latest show } } List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("WatchedDate", true, SortType.eDateTime)); contract.WatchedEpisodes = Sorting.MultiSort <Contract_Trakt_WatchedEpisode>(contract.WatchedEpisodes, sortCriteria); return(contract); }