From 949c6a87f25df8dce2633945dd7d31e6e2172959 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 16 May 2013 23:24:41 -0400 Subject: [PATCH] rework a-z picker a little --- MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs | 8 ++++---- MediaBrowser.Api/UserLibrary/ItemsService.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 48594d035..22098a368 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -133,9 +133,9 @@ namespace MediaBrowser.Api.UserLibrary /// IEnumerable{IbnStub}. private IEnumerable> FilterItems(GetItemsByName request, IEnumerable> items, User user) { - if (!string.IsNullOrEmpty(request.NameStartsWith)) + if (!string.IsNullOrEmpty(request.NameStartsWithOrGreater)) { - items = items.Where(i => i.Name.IndexOf(request.NameStartsWith, StringComparison.OrdinalIgnoreCase) == 0); + items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.Name, StringComparison.OrdinalIgnoreCase) < 1); } var filters = request.GetFilters().ToList(); @@ -309,8 +309,8 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public Guid? UserId { get; set; } - [ApiMember(Name = "NameStartsWith", Description = "Optional filter whose name begins with a prefix.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string NameStartsWith { get; set; } + [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string NameStartsWithOrGreater { get; set; } /// /// What to sort the results by diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 4ff60ce72..c57778fd6 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -127,8 +127,8 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string SeriesStatus { get; set; } - [ApiMember(Name = "NameStartsWith", Description = "Optional filter whose name begins with a prefix.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string NameStartsWith { get; set; } + [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string NameStartsWithOrGreater { get; set; } /// /// Gets or sets the air days. @@ -454,9 +454,9 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase)); } - if (!string.IsNullOrEmpty(request.NameStartsWith)) + if (!string.IsNullOrEmpty(request.NameStartsWithOrGreater)) { - items = items.Where(i => i.SortName.IndexOf(request.NameStartsWith, StringComparison.OrdinalIgnoreCase) == 0); + items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.OrdinalIgnoreCase) < 1); } // Filter by Series Status