public async Task <object> Get(GetUserViews request)
        {
            var user = _userManager.GetUserById(request.UserId);

            // Get everything
            var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();

            var query = new UserViewQuery
            {
                UserId = request.UserId
            };

            if (request.IncludeExternalContent.HasValue)
            {
                query.IncludeExternalContent = request.IncludeExternalContent.Value;
            }

            var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);

            var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
                       .ToArray();

            var result = new QueryResult <BaseItemDto>
            {
                Items            = dtos,
                TotalRecordCount = dtos.Length
            };

            return(ToOptimizedResult(result));
        }
Example #2
0
        public async Task <object> Get(GetUserViews request)
        {
            var query = new UserViewQuery
            {
                UserId = request.UserId
            };

            if (request.IncludeExternalContent.HasValue)
            {
                query.IncludeExternalContent = request.IncludeExternalContent.Value;
            }

            var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);

            var dtoOptions = GetDtoOptions(request);

            var user = _userManager.GetUserById(request.UserId);

            var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
                       .ToArray();

            var result = new QueryResult <BaseItemDto>
            {
                Items            = dtos,
                TotalRecordCount = dtos.Length
            };

            return(ToOptimizedResult(result));
        }
Example #3
0
        public object Get(GetUserViews request)
        {
            var query = new UserViewQuery
            {
                UserId = request.UserId
            };

            if (request.IncludeExternalContent.HasValue)
            {
                query.IncludeExternalContent = request.IncludeExternalContent.Value;
            }

            query.IncludeHidden = request.IncludeHidden;

            if (!string.IsNullOrWhiteSpace(request.PresetViews))
            {
                query.PresetViews = request.PresetViews.Split(',');
            }

            var app = _authContext.GetAuthorizationInfo(Request).Client ?? string.Empty;

            if (app.IndexOf("emby rt", StringComparison.OrdinalIgnoreCase) != -1)
            {
                query.PresetViews = new[] { CollectionType.Movies, CollectionType.TvShows };
            }

            var folders = _userViewManager.GetUserViews(query);

            var dtoOptions = GetDtoOptions(_authContext, request);
            var fields     = dtoOptions.Fields.ToList();

            fields.Add(ItemFields.PrimaryImageAspectRatio);
            fields.Add(ItemFields.DisplayPreferencesId);
            fields.Remove(ItemFields.BasicSyncInfo);
            dtoOptions.Fields = fields.ToArray();

            var user = _userManager.GetUserById(request.UserId);

            var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
                       .ToArray();

            var result = new QueryResult <BaseItemDto>
            {
                Items            = dtos,
                TotalRecordCount = dtos.Length
            };

            return(ToOptimizedResult(result));
        }
        public async Task <object> Get(GetUserViews request)
        {
            var query = new UserViewQuery
            {
                UserId = request.UserId
            };

            if (request.IncludeExternalContent.HasValue)
            {
                query.IncludeExternalContent = request.IncludeExternalContent.Value;
            }

            if (!string.IsNullOrWhiteSpace(request.PresetViews))
            {
                query.PresetViews = request.PresetViews.Split(',');
            }

            var app = AuthorizationContext.GetAuthorizationInfo(Request).Client ?? string.Empty;

            if (app.IndexOf("emby rt", StringComparison.OrdinalIgnoreCase) != -1)
            {
                query.PresetViews = new[] { CollectionType.Music, CollectionType.Movies, CollectionType.TvShows };
            }
            //query.PresetViews = new[] { CollectionType.Music, CollectionType.Movies, CollectionType.TvShows };

            var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);

            var dtoOptions = GetDtoOptions(request);

            dtoOptions.Fields = new List <ItemFields>();
            dtoOptions.Fields.Add(ItemFields.PrimaryImageAspectRatio);
            dtoOptions.Fields.Add(ItemFields.DisplayPreferencesId);

            var user = _userManager.GetUserById(request.UserId);

            var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
                       .ToArray();

            var result = new QueryResult <BaseItemDto>
            {
                Items            = dtos,
                TotalRecordCount = dtos.Length
            };

            return(ToOptimizedResult(result));
        }