mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-31 16:02:29 +01:00
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Linq;
|
|
using NzbDrone.Api.Episodes;
|
|
using NzbDrone.Api.Extensions;
|
|
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 SeriesRepository _seriesRepository;
|
|
|
|
public MissingModule(IEpisodeService episodeService, SeriesRepository seriesRepository)
|
|
:base("missing")
|
|
{
|
|
_episodeService = episodeService;
|
|
_seriesRepository = seriesRepository;
|
|
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 resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec);
|
|
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
|
|
|
|
return resource;
|
|
}
|
|
}
|
|
} |