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 ++++++++++++++++++++++- MediaBrowser.Controller/Library/ItemController.cs | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Controller') 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 /// diff --git a/MediaBrowser.Controller/Library/ItemController.cs b/MediaBrowser.Controller/Library/ItemController.cs index 0c62ce7d9..10648eca0 100644 --- a/MediaBrowser.Controller/Library/ItemController.cs +++ b/MediaBrowser.Controller/Library/ItemController.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; using MediaBrowser.Controller.Events; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Entities; -using MediaBrowser.Common.Configuration; namespace MediaBrowser.Controller.Library { -- cgit v1.2.3