From 0788f435c185e6e5fa63b439d1e8d08e5ad89e13 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Tue, 14 Aug 2012 15:06:25 -0400 Subject: Added GetItemsWithPerson --- MediaBrowser.Controller/Kernel.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Kernel.cs') diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index a8baec835..18598d014 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -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))); } + /// + /// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user + /// + /// Specify this to limit results to a specific PersonType + public IEnumerable 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; + }); + } /// /// Finds all recursive items within a top-level parent that contain the given genre and are allowed for the current user /// @@ -321,7 +344,7 @@ namespace MediaBrowser.Controller { return GetParentalAllowedRecursiveChildren(parent, userId).Where(f => f.ProductionYear.HasValue && f.ProductionYear == year); } - + /// /// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user /// -- cgit v1.2.3