aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs35
1 files changed, 30 insertions, 5 deletions
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
index 66aa35de9..88d080db5 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs
@@ -136,7 +136,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <value>The sort order.</value>
[ApiMember(Name = "SortOrder", Description = "Sort Order - Ascending,Descending", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
- public SortOrder? SortOrder { get; set; }
+ public string SortOrder { get; set; }
/// <summary>
/// Specify this to localize the search to a specific item or folder. Omit to use the root.
@@ -467,16 +467,41 @@ namespace MediaBrowser.Api.UserLibrary
/// Gets the order by.
/// </summary>
/// <returns>IEnumerable{ItemSortBy}.</returns>
- public string[] GetOrderBy()
+ public Tuple<string, SortOrder>[] GetOrderBy()
{
- var val = SortBy;
+ return GetOrderBy(SortBy, SortOrder);
+ }
+
+ public static Tuple<string, SortOrder>[] GetOrderBy(string sortBy, string requestedSortOrder)
+ {
+ var val = sortBy;
if (string.IsNullOrEmpty(val))
{
- return new string[] { };
+ return new Tuple<string, Model.Entities.SortOrder>[] { };
+ }
+
+ var vals = val.Split(',');
+ if (string.IsNullOrWhiteSpace(requestedSortOrder))
+ {
+ requestedSortOrder = "Ascending";
+ }
+
+ var sortOrders = requestedSortOrder.Split(',');
+
+ var result = new Tuple<string, Model.Entities.SortOrder>[vals.Length];
+
+ for (var i = 0; i < vals.Length; i++)
+ {
+ var sortOrderIndex = sortOrders.Length > i ? i : 0;
+
+ var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
+ var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending;
+
+ result[i] = new Tuple<string, Model.Entities.SortOrder>(vals[i], sortOrder);
}
- return val.Split(',');
+ return result;
}
}
}