Added GetItemsWithPerson

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti
2012-08-14 15:06:25 -04:00
parent ee1fa6e816
commit 0788f435c1
6 changed files with 83 additions and 5 deletions

View File

@@ -306,6 +306,29 @@ namespace MediaBrowser.Controller
return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.Studios != null && f.Studios.Any(s => s.Equals(studio, StringComparison.OrdinalIgnoreCase)));
}
/// <summary>
/// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user
/// </summary>
/// <param name="personType">Specify this to limit results to a specific PersonType</param>
public IEnumerable<BaseItem> GetItemsWithPerson(Folder parent, string person, PersonType? personType, Guid userId)
{
return GetParentalAllowedRecursiveChildren(parent, userId).Where(c =>
{
if (c.People != null)
{
if (personType.HasValue)
{
return c.People.Any(p => p.Name.Equals(person, StringComparison.OrdinalIgnoreCase) && p.PersonType == personType.Value);
}
else
{
return c.People.Any(p => p.Name.Equals(person, StringComparison.OrdinalIgnoreCase));
}
}
return false;
});
}
/// <summary>
/// Finds all recursive items within a top-level parent that contain the given genre and are allowed for the current user
/// </summary>
@@ -321,7 +344,7 @@ namespace MediaBrowser.Controller
{
return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.ProductionYear.HasValue && f.ProductionYear == year);
}
/// <summary>
/// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user
/// </summary>