using System.Collections.Generic; using NzbDrone.Core.Datastore; namespace Prowlarr.Http { public class PagingResource { public int Page { get; set; } public int PageSize { get; set; } public string SortKey { get; set; } public SortDirection SortDirection { get; set; } public List Filters { get; set; } public int TotalRecords { get; set; } public List Records { get; set; } } public static class PagingResourceMapper { public static PagingSpec MapToPagingSpec(this PagingResource pagingResource, string defaultSortKey = "Id", SortDirection defaultSortDirection = SortDirection.Ascending) { var pagingSpec = new PagingSpec { Page = pagingResource.Page, PageSize = pagingResource.PageSize, SortKey = pagingResource.SortKey, SortDirection = pagingResource.SortDirection, }; if (pagingResource.SortKey == null) { pagingSpec.SortKey = defaultSortKey; if (pagingResource.SortDirection == SortDirection.Default) { pagingSpec.SortDirection = defaultSortDirection; } } return pagingSpec; } } }