public object Get(GetYearIndex request)
        {
            var includeTypes = string.IsNullOrWhiteSpace(request.IncludeItemTypes)
             ? new string[] { }
             : request.IncludeItemTypes.Split(',');

            var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;

            var query = new InternalItemsQuery(user)
            {
                IncludeItemTypes = includeTypes,
                Recursive        = true,
                DtoOptions       = new DtoOptions(false)
                {
                    EnableImages = false
                }
            };

            var items = _libraryManager.GetItemList(query);

            var lookup = items
                         .ToLookup(i => i.ProductionYear ?? -1)
                         .OrderBy(i => i.Key)
                         .Select(i => new ItemIndex
            {
                ItemCount = i.Count(),
                Name      = i.Key == -1 ? string.Empty : i.Key.ToString(_usCulture)
            })
                         .ToList();

            return(ToOptimizedSerializedResultUsingCache(lookup));
        }
Beispiel #2
0
        public object Get(GetYearIndex request)
        {
            var includeTypes = string.IsNullOrWhiteSpace(request.IncludeItemTypes)
             ? new string[] { }
             : request.IncludeItemTypes.Split(',');

            Func <BaseItem, bool> filter = i =>
            {
                if (includeTypes.Length > 0)
                {
                    if (!includeTypes.Contains(i.GetType().Name, StringComparer.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }

                return(true);
            };

            IEnumerable <BaseItem> items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager, null, filter);

            var lookup = items
                         .ToLookup(i => i.ProductionYear ?? -1)
                         .OrderBy(i => i.Key)
                         .Select(i => new ItemIndex
            {
                ItemCount = i.Count(),
                Name      = i.Key == -1 ? string.Empty : i.Key.ToString(_usCulture)
            })
                         .ToList();

            return(ToOptimizedSerializedResultUsingCache(lookup));
        }
Beispiel #3
0
        public object Get(GetYearIndex request)
        {
            IEnumerable <BaseItem> items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager);

            if (!string.IsNullOrEmpty(request.IncludeItemTypes))
            {
                var vals = request.IncludeItemTypes.Split(',');
                items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase));
            }

            var lookup = items
                         .ToLookup(i => i.ProductionYear ?? -1)
                         .OrderBy(i => i.Key)
                         .Select(i => new ItemIndex
            {
                ItemCount = i.Count(),
                Name      = i.Key == -1 ? string.Empty : i.Key.ToString(_usCulture)
            })
                         .ToList();

            return(ToOptimizedSerializedResultUsingCache(lookup));
        }