Radarr/src/NzbDrone.Api/History/HistoryModule.cs

40 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using NzbDrone.Api.Mapping;
using NzbDrone.Core.Datastore;
2013-05-03 06:53:32 +00:00
using NzbDrone.Core.History;
namespace NzbDrone.Api.History
{
2013-05-13 06:12:19 +00:00
public class HistoryModule : NzbDroneRestModule<HistoryResource>
2013-05-03 06:53:32 +00:00
{
private readonly IHistoryService _historyService;
public HistoryModule(IHistoryService historyService)
{
_historyService = historyService;
2013-05-13 06:12:19 +00:00
GetResourcePaged = GetHistory;
2013-05-03 06:53:32 +00:00
}
2013-05-13 06:12:19 +00:00
private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
2013-05-03 06:53:32 +00:00
{
var episodeId = Request.Query.EpisodeId;
2013-05-10 22:33:04 +00:00
var pagingSpec = new PagingSpec<Core.History.History>
2013-05-03 06:53:32 +00:00
{
2013-05-13 06:12:19 +00:00
Page = pagingResource.Page,
PageSize = pagingResource.PageSize,
SortKey = pagingResource.SortKey,
SortDirection = pagingResource.SortDirection
2013-05-03 06:53:32 +00:00
};
if (episodeId.HasValue)
{
int i = (int)episodeId;
pagingSpec.FilterExpression = h => h.EpisodeId == i;
}
2013-05-13 06:12:19 +00:00
return ApplyToPage(_historyService.Paged, pagingSpec);
2013-05-03 06:53:32 +00:00
}
}
}