public ImageDetails GetDefaultFanartDetailsNoBlanks(ISession session) { Random fanartRandom = new Random(); ImageDetails details = null; if (GetDefaultFanart() == null) { // get a random fanart (only tvdb) if (this.AnimeTypeEnum == enAnimeType.Movie) { List<MovieDB_Fanart> fanarts = GetMovieDBFanarts(session); if (fanarts.Count == 0) return null; MovieDB_Fanart movieFanart = fanarts[fanartRandom.Next(0, fanarts.Count)]; details = new ImageDetails() { ImageType = JMMImageType.MovieDB_FanArt, ImageID = movieFanart.MovieDB_FanartID }; return details; } else { List<TvDB_ImageFanart> fanarts = GetTvDBImageFanarts(session); if (fanarts.Count == 0) return null; TvDB_ImageFanart tvFanart = fanarts[fanartRandom.Next(0, fanarts.Count)]; details = new ImageDetails() { ImageType = JMMImageType.TvDB_FanArt, ImageID = tvFanart.TvDB_ImageFanartID }; return details; } } else { ImageEntityType imageType = (ImageEntityType)GetDefaultFanart().ImageParentType; switch (imageType) { case ImageEntityType.TvDB_FanArt: TvDB_ImageFanartRepository repTvFanarts = new TvDB_ImageFanartRepository(); TvDB_ImageFanart tvFanart = repTvFanarts.GetByID(session, GetDefaultFanart(session).ImageParentID); if (tvFanart != null) details = new ImageDetails() { ImageType = JMMImageType.TvDB_FanArt, ImageID = tvFanart.TvDB_ImageFanartID }; return details; case ImageEntityType.Trakt_Fanart: Trakt_ImageFanartRepository repTraktFanarts = new Trakt_ImageFanartRepository(); Trakt_ImageFanart traktFanart = repTraktFanarts.GetByID(session, GetDefaultFanart(session).ImageParentID); if (traktFanart != null) details = new ImageDetails() { ImageType = JMMImageType.Trakt_Fanart, ImageID = traktFanart.Trakt_ImageFanartID }; return details; case ImageEntityType.MovieDB_FanArt: MovieDB_FanartRepository repMovieFanarts = new MovieDB_FanartRepository(); MovieDB_Fanart movieFanart = repMovieFanarts.GetByID(session, GetDefaultFanart(session).ImageParentID); if (movieFanart != null) details = new ImageDetails() { ImageType = JMMImageType.MovieDB_FanArt, ImageID = movieFanart.MovieDB_FanartID }; return details; } } return null; }
public ImageDetails GetDefaultFanartDetailsNoBlanks(ISessionWrapper session) { Random fanartRandom = new Random(); ImageDetails details = null; if (GetDefaultFanart(session) == null) { List<Contract_AniDB_Anime_DefaultImage> fanarts = Contract.AniDBAnime.Fanarts; if (fanarts == null || fanarts.Count == 0) return null; Contract_AniDB_Anime_DefaultImage art = fanarts[fanartRandom.Next(0, fanarts.Count)]; details = new ImageDetails() { ImageID = art.AniDB_Anime_DefaultImageID, ImageType = (JMMImageType)art.ImageType }; return details; } else { // TODO Move this to contract as well AniDB_Anime_DefaultImage fanart = GetDefaultFanart(); ImageEntityType imageType = (ImageEntityType) fanart.ImageParentType; switch (imageType) { case ImageEntityType.TvDB_FanArt: TvDB_ImageFanart tvFanart = RepoFactory.TvDB_ImageFanart.GetByID(session, fanart.ImageParentID); if (tvFanart != null) details = new ImageDetails() { ImageType = JMMImageType.TvDB_FanArt, ImageID = tvFanart.TvDB_ImageFanartID }; return details; case ImageEntityType.Trakt_Fanart: Trakt_ImageFanart traktFanart = RepoFactory.Trakt_ImageFanart.GetByID(session, fanart.ImageParentID); if (traktFanart != null) details = new ImageDetails() { ImageType = JMMImageType.Trakt_Fanart, ImageID = traktFanart.Trakt_ImageFanartID }; return details; case ImageEntityType.MovieDB_FanArt: MovieDB_Fanart movieFanart = RepoFactory.MovieDB_Fanart.GetByID(session, fanart.ImageParentID); if (movieFanart != null) details = new ImageDetails() { ImageType = JMMImageType.MovieDB_FanArt, ImageID = movieFanart.MovieDB_FanartID }; return details; } } return null; }
public ImageDetails GetDefaultPosterDetailsNoBlanks(ISession session) { ImageDetails details = new ImageDetails() { ImageType = JMMImageType.AniDB_Cover, ImageID = this.AnimeID }; AniDB_Anime_DefaultImage defaultPoster = GetDefaultPoster(session); if (defaultPoster == null) return details; else { ImageEntityType imageType = (ImageEntityType)defaultPoster.ImageParentType; switch (imageType) { case ImageEntityType.AniDB_Cover: return details; case ImageEntityType.TvDB_Cover: TvDB_ImagePosterRepository repTvPosters = new TvDB_ImagePosterRepository(); TvDB_ImagePoster tvPoster = repTvPosters.GetByID(session, defaultPoster.ImageParentID); if (tvPoster != null) details = new ImageDetails() { ImageType = JMMImageType.TvDB_Cover, ImageID = tvPoster.TvDB_ImagePosterID }; return details; case ImageEntityType.Trakt_Poster: Trakt_ImagePosterRepository repTraktPosters = new Trakt_ImagePosterRepository(); Trakt_ImagePoster traktPoster = repTraktPosters.GetByID(session, defaultPoster.ImageParentID); if (traktPoster != null) details = new ImageDetails() { ImageType = JMMImageType.Trakt_Poster, ImageID = traktPoster.Trakt_ImagePosterID }; return details; case ImageEntityType.MovieDB_Poster: MovieDB_PosterRepository repMoviePosters = new MovieDB_PosterRepository(); MovieDB_Poster moviePoster = repMoviePosters.GetByID(session, defaultPoster.ImageParentID); if (moviePoster != null) details = new ImageDetails() { ImageType = JMMImageType.MovieDB_Poster, ImageID = moviePoster.MovieDB_PosterID }; return details; } } return details; }
public ImageDetails GetDefaultWideBannerDetailsNoBlanks(ISessionWrapper session) { Random bannerRandom = new Random(); ImageDetails details = null; AniDB_Anime_DefaultImage banner = GetDefaultWideBanner(); if (banner == null) { // get a random banner (only tvdb) if (this.AnimeTypeEnum == enAnimeType.Movie) { // MovieDB doesn't have banners return null; } else { List<Contract_AniDB_Anime_DefaultImage> banners = Contract.AniDBAnime.Banners; if (banners == null || banners.Count == 0) return null; Contract_AniDB_Anime_DefaultImage art = banners[bannerRandom.Next(0, banners.Count)]; details = new ImageDetails() { ImageID = art.AniDB_Anime_DefaultImageID, ImageType = (JMMImageType) art.ImageType }; return details; } } else { ImageEntityType imageType = (ImageEntityType) banner.ImageParentType; switch (imageType) { case ImageEntityType.TvDB_Banner: details = new ImageDetails() { ImageType = JMMImageType.TvDB_Banner, ImageID = banner.ToContract(session).TVWideBanner.TvDB_ImageWideBannerID }; return details; } } return null; }