public Contract_AniDBAnime ToContract(ISession session, bool getDefaultImages, List<AniDB_Anime_Title> titles) { Contract_AniDBAnime contract = new Contract_AniDBAnime(); contract.AirDate = this.AirDate; contract.AllCategories = this.AllCategories; contract.AllCinemaID = this.AllCinemaID; contract.AllTags = this.AllTags; contract.AllTitles = this.AllTitles; contract.AnimeID = this.AnimeID; contract.AnimeNfo = this.AnimeNfo; contract.AnimePlanetID = this.AnimePlanetID; contract.AnimeType = this.AnimeType; contract.ANNID = this.ANNID; contract.AvgReviewRating = this.AvgReviewRating; contract.AwardList = this.AwardList; contract.BeginYear = this.BeginYear; contract.Description = this.Description; contract.DateTimeDescUpdated = this.DateTimeDescUpdated; contract.DateTimeUpdated = this.DateTimeUpdated; contract.EndDate = this.EndDate; contract.EndYear = this.EndYear; contract.EpisodeCount = this.EpisodeCount; contract.EpisodeCountNormal = this.EpisodeCountNormal; contract.EpisodeCountSpecial = this.EpisodeCountSpecial; contract.ImageEnabled = this.ImageEnabled; contract.LatestEpisodeNumber = this.LatestEpisodeNumber; contract.MainTitle = this.MainTitle; contract.Picname = this.Picname; contract.Rating = this.Rating; contract.Restricted = this.Restricted; contract.ReviewCount = this.ReviewCount; contract.TempRating = this.TempRating; contract.TempVoteCount = this.TempVoteCount; contract.URL = this.URL; contract.VoteCount = this.VoteCount; if (titles == null) contract.FormattedTitle = this.GetFormattedTitle(session); else contract.FormattedTitle = GetFormattedTitle(titles); contract.DisableExternalLinksFlag = this.DisableExternalLinksFlag; if (getDefaultImages) { AniDB_Anime_DefaultImage defFanart = this.GetDefaultFanart(session); if (defFanart != null) contract.DefaultImageFanart = defFanart.ToContract(session); AniDB_Anime_DefaultImage defPoster = this.GetDefaultPoster(session); if (defPoster != null) contract.DefaultImagePoster = defPoster.ToContract(session); AniDB_Anime_DefaultImage defBanner = this.GetDefaultWideBanner(session); if (defBanner != null) contract.DefaultImageWideBanner = defBanner.ToContract(session); } return contract; }
private Contract_AniDBAnime GenerateContract(List<AniDB_Anime_Title> titles, DefaultAnimeImages defaultImages, List<Contract_AniDB_Character> characters, IEnumerable<MovieDB_Fanart> movDbFanart, IEnumerable<TvDB_ImageFanart> tvDbFanart, IEnumerable<TvDB_ImageWideBanner> tvDbBanners) { Contract_AniDBAnime contract = new Contract_AniDBAnime(); contract.AirDate = this.AirDate; contract.AllCinemaID = this.AllCinemaID; //TODO this can contract.AllTags = new HashSet<string>( this.AllTags.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries) .Select(a => a.Trim()) .Where(a => !string.IsNullOrEmpty(a)), StringComparer.InvariantCultureIgnoreCase); contract.AllTitles = new HashSet<string>( this.AllTitles.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries) .Select(a => a.Trim()) .Where(a => !string.IsNullOrEmpty(a)), StringComparer.InvariantCultureIgnoreCase); contract.AnimeID = this.AnimeID; contract.AnimeNfo = this.AnimeNfo; contract.AnimePlanetID = this.AnimePlanetID; contract.AnimeType = this.AnimeType; contract.ANNID = this.ANNID; contract.AvgReviewRating = this.AvgReviewRating; contract.AwardList = this.AwardList; contract.BeginYear = this.BeginYear; contract.Description = this.Description; contract.DateTimeDescUpdated = this.DateTimeDescUpdated; contract.DateTimeUpdated = this.DateTimeUpdated; contract.EndDate = this.EndDate; contract.EndYear = this.EndYear; contract.EpisodeCount = this.EpisodeCount; contract.EpisodeCountNormal = this.EpisodeCountNormal; contract.EpisodeCountSpecial = this.EpisodeCountSpecial; contract.ImageEnabled = this.ImageEnabled; contract.LatestEpisodeNumber = this.LatestEpisodeNumber; contract.MainTitle = this.MainTitle; contract.Picname = this.Picname; contract.Rating = this.Rating; contract.Restricted = this.Restricted; contract.ReviewCount = this.ReviewCount; contract.TempRating = this.TempRating; contract.TempVoteCount = this.TempVoteCount; contract.URL = this.URL; contract.VoteCount = this.VoteCount; contract.FormattedTitle = GetFormattedTitle(titles); contract.DisableExternalLinksFlag = this.DisableExternalLinksFlag; contract.Characters = characters; if (defaultImages != null) { contract.DefaultImageFanart = defaultImages.Fanart?.ToContract(); contract.DefaultImagePoster = defaultImages.Poster?.ToContract(); contract.DefaultImageWideBanner = defaultImages.WideBanner?.ToContract(); } if (AnimeTypeEnum == enAnimeType.Movie) { contract.Fanarts = movDbFanart?.Select(a => new Contract_AniDB_Anime_DefaultImage { ImageType = (int)JMMImageType.MovieDB_FanArt, MovieFanart = a.ToContract(), AniDB_Anime_DefaultImageID = a.MovieDB_FanartID }) .ToList(); } else // Not a movie { contract.Fanarts = tvDbFanart?.Select(a => new Contract_AniDB_Anime_DefaultImage { ImageType = (int)JMMImageType.TvDB_FanArt, TVFanart = a.ToContract(), AniDB_Anime_DefaultImageID = a.TvDB_ImageFanartID }) .ToList(); contract.Banners = tvDbBanners?.Select(a => new Contract_AniDB_Anime_DefaultImage { ImageType = (int)JMMImageType.TvDB_Banner, TVWideBanner = a.ToContract(), AniDB_Anime_DefaultImageID = a.TvDB_ImageWideBannerID }) .ToList(); } if (contract.Fanarts?.Count == 0) contract.Fanarts = null; if (contract.Banners?.Count == 0) contract.Banners = null; return contract; }