From 032f3d376b3818bdff98512229fb96fdfd9f37bb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Sep 2013 01:13:43 -0400 Subject: added more sorting to ibn endpoints --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 32 ++++------------------------ 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 5013f685a..288b67057 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -87,7 +87,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "Albums", Description = "Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Albums { get; set; } - + /// /// Limit results to items containing specific years /// @@ -95,13 +95,6 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "Years", Description = "Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Years { get; set; } - /// - /// Gets or sets the image types. - /// - /// The image types. - [ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] - public string ImageTypes { get; set; } - /// /// Gets or sets the item ids. /// @@ -174,7 +167,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "MinIndexNumber", Description = "Optional filter index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? MinIndexNumber { get; set; } - + /// /// Gets the order by. /// @@ -620,7 +613,7 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(i => !string.IsNullOrEmpty(i.MediaType) && types.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase)); } - var imageTypes = GetImageTypes(request).ToArray(); + var imageTypes = request.GetImageTypes().ToArray(); if (imageTypes.Length > 0) { items = items.Where(item => imageTypes.Any(imageType => HasImage(item, imageType))); @@ -717,7 +710,7 @@ namespace MediaBrowser.Api.UserLibrary /// The item. /// Type of the image. /// true if the specified item has image; otherwise, false. - private static bool HasImage(BaseItem item, ImageType imageType) + internal static bool HasImage(BaseItem item, ImageType imageType) { if (imageType == ImageType.Backdrop) { @@ -772,23 +765,6 @@ namespace MediaBrowser.Api.UserLibrary return items; } - - /// - /// Gets the image types. - /// - /// The request. - /// IEnumerable{ImageType}. - private static IEnumerable GetImageTypes(GetItems request) - { - var val = request.ImageTypes; - - if (string.IsNullOrEmpty(val)) - { - return new ImageType[] { }; - } - - return val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)); - } } /// -- cgit v1.2.3