using System.Collections.Generic; using System.Linq; namespace ErsatzTV.Core.Scheduling { public class MultiCollectionGrouper { public static List GroupMediaItems(IList collections) { var result = new List(); foreach (CollectionWithItems collection in collections.Where(collection => collection.MediaItems.Any())) { if (collection.ScheduleAsGroup) { result.Add(new MultiCollectionGroup(collection)); } else { result.AddRange(collection.MediaItems.Map(i => new GroupedMediaItem { First = i })); } } return result; } } }