@ -17,15 +17,26 @@ namespace NzbDrone.Api
public static class PagingResourceMapper
{
public static PagingSpec < TModel > MapToPagingSpec < TResource , TModel > ( this PagingResource < TResource > paging Spec )
public static PagingSpec < TModel > MapToPagingSpec < TResource , TModel > ( this PagingResource < TResource > paging Resource, string defaultSortKey = "Id" , SortDirection defaultSortDirection = SortDirection . Ascending )
{
return new PagingSpec < TModel >
var pagingSpec = new PagingSpec < TModel >
{
Page = paging Spec . Page ,
PageSize = paging Spec . PageSize ,
SortKey = paging Spec . SortKey ,
SortDirection = paging Spec . SortDirection ,
Page = paging Resource . Page ,
PageSize = paging Resource . PageSize ,
SortKey = paging Resource . SortKey ,
SortDirection = paging Resource . SortDirection ,
} ;
if ( pagingResource . SortKey = = null )
{
pagingSpec . SortKey = defaultSortKey ;
if ( pagingResource . SortDirection = = SortDirection . Default )
{
pagingSpec . SortDirection = defaultSortDirection ;
}
}
return pagingSpec ;
}
}
}