Ejemplo n.º 1
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(request.Id);

            List <Guid> trailerIds = null;

            var hasTrailers = item as IHasTrailers;

            if (hasTrailers != null)
            {
                trailerIds = hasTrailers.GetTrailerIds();
            }
            else
            {
                trailerIds = new List <Guid>();
            }

            var dtoOptions = GetDtoOptions(_authContext, request);

            var dtos = trailerIds
                       .Select(_libraryManager.GetItemById)
                       .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
                       .ToArray();

            return(ToOptimizedSerializedResultUsingCache(dtos));
        }
Ejemplo n.º 2
0
        private List <BaseItemDto> GetAsync(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

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

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

            var trailerIds = new List <Guid>();

            var hasTrailers = item as IHasTrailers;

            if (hasTrailers != null)
            {
                trailerIds = hasTrailers.LocalTrailerIds;
            }

            var dtos = trailerIds
                       .Select(_libraryManager.GetItemById)
                       .OrderBy(i => i.SortName)
                       .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));

            return(dtos.ToList());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(_authContext, request);

            var dtos = item.GetExtras(new[] { ExtraType.Trailer })
                       .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
                       .ToArray();

            return(ToOptimizedResult(dtos));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

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

            // 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 items = item.LocalTrailerIds.Select(_itemRepo.RetrieveItem).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToList();

            return(ToOptimizedResult(items));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);

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

            var dtoBuilder = new DtoBuilder(Logger, _libraryManager);

            var items = item.LocalTrailers.Select(i => dtoBuilder.GetBaseItemDto(i, user, fields)).AsParallel().Select(t => t.Result).ToList();

            return(ToOptimizedResult(items));
        }
Ejemplo n.º 6
0
        private Task <BaseItemDto[]> GetAsync(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);

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

            var tasks = item.LocalTrailerIds
                        .Select(_itemRepo.RetrieveItem)
                        .OrderBy(i => i.SortName)
                        .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));

            return(Task.WhenAll(tasks));
        }
Ejemplo n.º 7
0
        private List <BaseItemDto> GetAsync(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

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

            var trailerIds = new List <Guid>();

            var hasTrailers = item as IHasTrailers;

            if (hasTrailers != null)
            {
                trailerIds = hasTrailers.GetTrailerIds();
            }

            var dtoOptions = GetDtoOptions(request);

            var dtos = trailerIds
                       .Select(_libraryManager.GetItemById)
                       .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));

            return(dtos.ToList());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var user = _userManager.GetUserById(request.UserId);

            var item = string.IsNullOrEmpty(request.Id) ? _libraryManager.GetUserRootFolder() : _libraryManager.GetItemById(request.Id);

            var dtoOptions = GetDtoOptions(_authContext, request);

            var dtosExtras = item.GetExtras(new[] { ExtraType.Trailer })
                             .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
                             .ToArray();

            if (item is IHasTrailers hasTrailers)
            {
                var trailers     = hasTrailers.GetTrailers();
                var dtosTrailers = _dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item);
                var allTrailers  = new BaseItemDto[dtosExtras.Length + dtosTrailers.Count];
                dtosExtras.CopyTo(allTrailers, 0);
                dtosTrailers.CopyTo(allTrailers, dtosExtras.Length);
                return(ToOptimizedResult(allTrailers));
            }

            return(ToOptimizedResult(dtosExtras));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var result = GetAsync(request);

            return(ToOptimizedSerializedResultUsingCache(result));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>System.Object.</returns>
        public object Get(GetLocalTrailers request)
        {
            var result = GetAsync(request);

            return(ToOptimizedResult(result));
        }