@ -17,15 +17,26 @@ namespace NzbDrone.Api
public static class PagingResourceMapper
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 ,
Page = paging Resource . Page ,
PageSize = paging Spec . PageSize ,
PageSize = paging Resource . PageSize ,
SortKey = paging Spec . SortKey ,
SortKey = paging Resource . SortKey ,
SortDirection = paging Spec . SortDirection ,
SortDirection = paging Resource . SortDirection ,
} ;
} ;
if ( pagingResource . SortKey = = null )
{
pagingSpec . SortKey = defaultSortKey ;
if ( pagingResource . SortDirection = = SortDirection . Default )
{
pagingSpec . SortDirection = defaultSortDirection ;
}
}
return pagingSpec ;
}
}
}
}
}
}