1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 02:37:40 +00:00
Sonarr/NzbDrone.Api/Missing/MissingModule.cs
2013-06-03 21:00:07 -07:00

40 lines
No EOL
1.4 KiB
C#

using System.Linq;
using NzbDrone.Api.Episodes;
using NzbDrone.Common;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Missing
{
public class MissingModule : NzbDroneRestModule<EpisodeResource>
{
private readonly IEpisodeService _episodeService;
private readonly SeriesService _seriesService;
public MissingModule(IEpisodeService episodeService, SeriesService seriesService)
:base("missing")
{
_episodeService = episodeService;
_seriesService = seriesService;
GetResourcePaged = GetMissingEpisodes;
}
private PagingResource<EpisodeResource> GetMissingEpisodes(PagingResource<EpisodeResource> pagingResource)
{
var pagingSpec = new PagingSpec<Episode>
{
Page = pagingResource.Page,
PageSize = pagingResource.PageSize,
SortKey = pagingResource.SortKey,
SortDirection = pagingResource.SortDirection
};
var episodeResources = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec);
var series = _seriesService.GetSeriesInList(episodeResources.Records.SelectDistinct(e => e.SeriesId));
episodeResources.Records.Join(series, episode => episode.SeriesId, s => s.Id, episode => episode.Series);
return episodeResources;
}
}
}