Added LibraryManager.Search

This commit is contained in:
LukePulverenti 2013-03-12 00:26:23 -04:00
parent 7f2716bd0d
commit 3f44324623
3 changed files with 26 additions and 4 deletions

View File

@ -387,7 +387,7 @@ namespace MediaBrowser.Api.UserLibrary
if (!string.IsNullOrEmpty(term))
{
items = items.Where(i => i.Name.StartsWith(term, StringComparison.OrdinalIgnoreCase));
items = _libraryManager.Search(items, request.SearchTerm);
}
return items;

View File

@ -173,5 +173,13 @@ namespace MediaBrowser.Controller.Library
/// <returns>IEnumerable{BaseItem}.</returns>
IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy,
SortOrder sortOrder);
/// <summary>
/// Sorts the specified items.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="searchTerm">The search term.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
IEnumerable<BaseItem> Search(IEnumerable<BaseItem> items, string searchTerm);
}
}

View File

@ -1,5 +1,4 @@
using System.Collections;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
@ -12,7 +11,6 @@ using MediaBrowser.Controller.ScheduledTasks;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations.Library.Resolvers;
using MediaBrowser.Server.Implementations.ScheduledTasks;
using MoreLinq;
using System;
@ -769,5 +767,21 @@ namespace MediaBrowser.Server.Implementations.Library
return comparer;
}
/// <summary>
/// Sorts the specified items.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="searchTerm">The search term.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
public IEnumerable<BaseItem> Search(IEnumerable<BaseItem> items, string searchTerm)
{
if (string.IsNullOrEmpty(searchTerm))
{
throw new ArgumentNullException("searchTerm");
}
return items.Where(i => i.Name.StartsWith(searchTerm, StringComparison.OrdinalIgnoreCase));
}
}
}