private SeriesStatistics MapSeriesStatistics(List <SeasonStatistics> seasonStatistics) { var seriesStatistics = new SeriesStatistics { SeasonStatistics = seasonStatistics, SeriesId = seasonStatistics.First().SeriesId, EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount), EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount), TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount), SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk) }; var nextAiring = seasonStatistics.Where(s => s.NextAiring != null) .OrderBy(s => s.NextAiring) .FirstOrDefault(); var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null) .OrderBy(s => s.PreviousAiring) .LastOrDefault(); seriesStatistics.NextAiringString = nextAiring != null ? nextAiring.NextAiringString : null; seriesStatistics.PreviousAiringString = previousAiring != null ? previousAiring.PreviousAiringString : null; return(seriesStatistics); }
private SeriesStatistics MapSeriesStatistics(List<SeasonStatistics> seasonStatistics) { var seriesStatistics = new SeriesStatistics { SeasonStatistics = seasonStatistics, SeriesId = seasonStatistics.First().SeriesId, EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount), EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount), TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount), SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk) }; var nextAiring = seasonStatistics.Where(s => s.NextAiring != null) .OrderBy(s => s.NextAiring) .FirstOrDefault(); var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null) .OrderBy(s => s.PreviousAiring) .LastOrDefault(); seriesStatistics.NextAiringString = nextAiring != null ? nextAiring.NextAiringString : null; seriesStatistics.PreviousAiringString = previousAiring != null ? previousAiring.PreviousAiringString : null; return seriesStatistics; }