2013-06-04 05:59:24 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NzbDrone.Api.Episodes;
|
2013-06-04 08:18:12 +02:00
|
|
|
|
using NzbDrone.Api.Extensions;
|
2013-06-04 05:59:24 +02:00
|
|
|
|
using NzbDrone.Common;
|
2013-05-14 05:21:37 +02:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Missing
|
|
|
|
|
{
|
2013-05-14 05:21:37 +02:00
|
|
|
|
public class MissingModule : NzbDroneRestModule<EpisodeResource>
|
2013-03-21 04:02:57 +01:00
|
|
|
|
{
|
2013-04-01 08:22:16 +02:00
|
|
|
|
private readonly IEpisodeService _episodeService;
|
2013-06-04 08:18:12 +02:00
|
|
|
|
private readonly SeriesRepository _seriesRepository;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
|
2013-06-04 08:18:12 +02:00
|
|
|
|
public MissingModule(IEpisodeService episodeService, SeriesRepository seriesRepository)
|
2013-05-14 05:21:37 +02:00
|
|
|
|
:base("missing")
|
2013-03-21 04:02:57 +01:00
|
|
|
|
{
|
|
|
|
|
_episodeService = episodeService;
|
2013-06-04 08:18:12 +02:00
|
|
|
|
_seriesRepository = seriesRepository;
|
2013-05-13 08:12:19 +02:00
|
|
|
|
GetResourcePaged = GetMissingEpisodes;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-14 05:21:37 +02:00
|
|
|
|
private PagingResource<EpisodeResource> GetMissingEpisodes(PagingResource<EpisodeResource> pagingResource)
|
2013-03-21 04:02:57 +01:00
|
|
|
|
{
|
2013-05-02 07:50:34 +02:00
|
|
|
|
var pagingSpec = new PagingSpec<Episode>
|
2013-05-13 08:12:19 +02:00
|
|
|
|
{
|
|
|
|
|
Page = pagingResource.Page,
|
|
|
|
|
PageSize = pagingResource.PageSize,
|
|
|
|
|
SortKey = pagingResource.SortKey,
|
|
|
|
|
SortDirection = pagingResource.SortDirection
|
|
|
|
|
};
|
|
|
|
|
|
2013-06-04 08:18:12 +02:00
|
|
|
|
var resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec);
|
|
|
|
|
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
|
2013-06-04 05:59:24 +02:00
|
|
|
|
|
2013-06-04 08:18:12 +02:00
|
|
|
|
return resource;
|
2013-03-21 04:02:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|