Added some tests for PagingSpecExtensions

Allow specials in missing
Dropped ListSortDirection
This commit is contained in:
Mark McDowall
2013-05-07 00:22:19 -07:00
parent d37c8c26c2
commit f4dd6adc6a
12 changed files with 131 additions and 92 deletions
+8 -3
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
@@ -12,7 +11,13 @@ namespace NzbDrone.Core.Datastore
public int PageSize { get; set; }
public int TotalRecords { get; set; }
public string SortKey { get; set; }
public ListSortDirection SortDirection { get; set; }
public List<TModel> Records { get; set; }
public SortDirection SortDirection { get; set; }
public List<TModel> Records { get; set; }
}
public enum SortDirection
{
Ascending,
Descending
}
}
@@ -20,6 +20,13 @@ namespace NzbDrone.Core.Datastore
return (pagingSpec.Page - 1)*pagingSpec.PageSize;
}
public static Marr.Data.QGen.SortDirection ToSortDirection<TModel>(this PagingSpec<TModel> pagingSpec)
{
if (pagingSpec.SortDirection == SortDirection.Descending) return Marr.Data.QGen.SortDirection.Desc;
return Marr.Data.QGen.SortDirection.Asc;
}
private static Expression<Func<TModel, object>> CreateExpression<TModel>(string propertyName)
{
Type type = typeof(TModel);