Beispiel #1
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (!string.IsNullOrWhiteSpace(request.UserId)
                                  ? user.RootFolder
                                  : _libraryManager.RootFolder)
                           : _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(_authContext, request);

            var video = item as Video;

            BaseItemDto[] items;
            if (video != null)
            {
                items = video.GetAdditionalParts()
                        .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
                        .ToArray();
            }
            else
            {
                items = new BaseItemDto[] { };
            }

            var result = new ItemsResult
            {
                Items            = items,
                TotalRecordCount = items.Length
            };

            return(ToOptimizedSerializedResultUsingCache(result));
        }
Beispiel #2
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (request.UserId.HasValue
                                  ? user.RootFolder
                                  : _libraryManager.RootFolder)
                           : _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(request);

            var video = (Video)item;

            var items = video.GetAdditionalParts()
                        .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
                        .ToArray();

            var result = new ItemsResult
            {
                Items            = items,
                TotalRecordCount = items.Length
            };

            return(ToOptimizedSerializedResultUsingCache(result));
        }
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (request.UserId.HasValue
                                  ? user.RootFolder
                                  : (Folder)_libraryManager.RootFolder)
                           : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);

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

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);

            var video = (Video)item;

            var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem)
                        .OrderBy(i => i.SortName)
                        .Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, video))
                        .Select(t => t.Result)
                        .ToArray();

            var result = new ItemsResult
            {
                Items            = items,
                TotalRecordCount = items.Length
            };

            return(ToOptimizedResult(result));
        }
Beispiel #4
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (request.UserId.HasValue
                                  ? user.RootFolder
                                  : _libraryManager.RootFolder)
                           : _libraryManager.GetItemById(request.Id);

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

            var video = (Video)item;

            var items = video.GetAdditionalParts()
                        .Select(i => _dtoService.GetBaseItemDto(i, fields, user, video))
                        .ToArray();

            var result = new ItemsResult
            {
                Items            = items,
                TotalRecordCount = items.Length
            };

            return(ToOptimizedSerializedResultUsingCache(result));
        }
Beispiel #5
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetAdditionalParts request)
        {
            var user = !request.UserId.Equals(Guid.Empty) ? _userManager.GetUserById(request.UserId) : null;

            var item = string.IsNullOrEmpty(request.Id)
                           ? (!request.UserId.Equals(Guid.Empty)
                                  ? _libraryManager.GetUserRootFolder()
                                  : _libraryManager.RootFolder)
                           : _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(_authContext, request);

            BaseItemDto[] items;
            if (item is Video video)
            {
                items = video.GetAdditionalParts()
                        .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
                        .ToArray();
            }
            else
            {
                items = Array.Empty <BaseItemDto>();
            }

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

            return(ToOptimizedResult(result));
        }