private Task <Either <ProcessFailedResult, int> > GetMappedTvDbSeriesId(int aniDbSeriesId, ProcessResultContext resultContext) { return(_mappingList.GetSeriesMappingFromAniDb(aniDbSeriesId, resultContext) .BindAsync(sm => sm.Ids.TvDbSeriesId.ToEither(resultContext.Failed("No TvDb Id found on matching mapping")))); }
private ISeriesMapping SetUpSeriesMapping(int aniDbSeriesId, int tvDbSeriesId) { var seriesMapping = Substitute.For <ISeriesMapping>(); seriesMapping.Ids.Returns(new SeriesIds(aniDbSeriesId, tvDbSeriesId, Option <int> .None, Option <int> .None)); _mappingList.GetSeriesMappingFromAniDb(aniDbSeriesId, Arg.Any <ProcessResultContext>()) .Returns(Right <ProcessFailedResult, ISeriesMapping>(seriesMapping)); return(seriesMapping); }
private Task <Either <ProcessFailedResult, TvDbEpisodeData> > MapEpisodeDataAsync(AniDbSeriesData aniDbSeriesData, AniDbEpisodeData aniDbEpisodeData, ProcessResultContext resultContext) { var seriesMapping = _mappingList.GetSeriesMappingFromAniDb(aniDbSeriesData.Id, resultContext); return(seriesMapping.BindAsync(sm => { var episodeGroupMapping = sm.GetEpisodeGroupMapping(aniDbEpisodeData.EpisodeNumber); var tvDbEpisodeData = _episodeMapper.MapAniDbEpisodeAsync(aniDbEpisodeData.EpisodeNumber.Number, sm, episodeGroupMapping); return tvDbEpisodeData.Match( d => Right <ProcessFailedResult, TvDbEpisodeData>(d), () => resultContext.Failed("Found a series mapping but failed to map the episode to TvDb")); })); }