Skip to content

Commit

Permalink
Removed redundant code and fixed incorrect ImageType
Browse files Browse the repository at this point in the history
- Removed code from first AniDB_Anime.GenerateContract which repeats
  work that is done earlier in the method (ie. the image info is retrieved
  on line 1987-1994, and they're converted to contracts in the GenerateContract
  call on line 1997).
- Fixed the contract generation for TvDB Banners in second
  AniDB_Anime.GenerateContract method. It was using JMMImageType.TvDB_FanArt,
  and should have been JMMImageType.TvDB_Banner.
  • Loading branch information
pmcleish committed Sep 9, 2016
1 parent ecf1d8e commit a734f9c
Showing 1 changed file with 1 addition and 43 deletions.
44 changes: 1 addition & 43 deletions JMMServer/Entities/AniDB_Anime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,48 +2003,6 @@ private Contract_AniDBAnime GenerateContract(ISessionWrapper session, List<AniDB
contract.DefaultImagePoster = defPoster?.ToContract(session);
contract.DefaultImageWideBanner = defBanner?.ToContract(session);

// generate Fanarts and Banners
if (this.AnimeTypeEnum == enAnimeType.Movie)
{
List<MovieDB_Fanart> fanarts = GetMovieDBFanarts(session);
if (fanarts.Count > 0)
{
contract.Fanarts = new List<Contract_AniDB_Anime_DefaultImage>();
fanarts.ForEach(a => contract.Fanarts.Add(new Contract_AniDB_Anime_DefaultImage()
{
ImageType = (int) JMMImageType.MovieDB_FanArt,
MovieFanart = a.ToContract(),
AniDB_Anime_DefaultImageID = a.MovieDB_FanartID
}));
}
// MovieDB doesn't have banners
}
else
{
List<TvDB_ImageFanart> fanarts = GetTvDBImageFanarts(session);
if (fanarts.Count > 0)
{
contract.Fanarts = new List<Contract_AniDB_Anime_DefaultImage>();
fanarts.ForEach(a => contract.Fanarts.Add(new Contract_AniDB_Anime_DefaultImage()
{
ImageType = (int) JMMImageType.TvDB_FanArt,
TVFanart = a.ToContract(),
AniDB_Anime_DefaultImageID = a.TvDB_ImageFanartID
}));
}
List<TvDB_ImageWideBanner> banners = GetTvDBImageWideBanners(session);
if (banners.Count > 0)
{
contract.Banners = new List<Contract_AniDB_Anime_DefaultImage>();
banners.ForEach(a => contract.Banners.Add(new Contract_AniDB_Anime_DefaultImage()
{
ImageType = (int) JMMImageType.TvDB_Banner,
TVWideBanner = a.ToContract(),
AniDB_Anime_DefaultImageID = a.TvDB_ImageWideBannerID
}));
}
}

return contract;
}

Expand Down Expand Up @@ -2126,7 +2084,7 @@ private Contract_AniDBAnime GenerateContract(List<AniDB_Anime_Title> titles, Def
.ToList();
contract.Banners = tvDbBanners?.Select(a => new Contract_AniDB_Anime_DefaultImage
{
ImageType = (int)JMMImageType.TvDB_FanArt,
ImageType = (int)JMMImageType.TvDB_Banner,
TVWideBanner = a.ToContract(),
AniDB_Anime_DefaultImageID = a.TvDB_ImageWideBannerID
})
Expand Down

1 comment on commit a734f9c

@da3dsoul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks

Please sign in to comment.