Beispiel #1
0
        public async Task <object> Get(GetLatestChannelItems request)
        {
            var result = await _channelManager.GetLatestChannelItems(new AllChannelMediaQuery
            {
                Limit      = request.Limit,
                StartIndex = request.StartIndex,
                ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(),
                UserId     = request.UserId,
                Filters    = request.GetFilters().ToArray(),
                Fields     = request.GetItemFields()
            }, CancellationToken.None).ConfigureAwait(false);

            return(ToOptimizedResult(result));
        }
Beispiel #2
0
        public async Task <object> Get(GetLatestChannelItems request)
        {
            var user = string.IsNullOrEmpty(request.UserId)
                ? null
                : _userManager.GetUserById(request.UserId);

            var query = new InternalItemsQuery(user)
            {
                Limit      = request.Limit,
                StartIndex = request.StartIndex,
                ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(),
                DtoOptions = new Controller.Dto.DtoOptions
                {
                    Fields = request.GetItemFields()
                }
            };

            foreach (var filter in request.GetFilters())
            {
                switch (filter)
                {
                case ItemFilter.Dislikes:
                    query.IsLiked = false;
                    break;

                case ItemFilter.IsFavorite:
                    query.IsFavorite = true;
                    break;

                case ItemFilter.IsFavoriteOrLikes:
                    query.IsFavoriteOrLiked = true;
                    break;

                case ItemFilter.IsFolder:
                    query.IsFolder = true;
                    break;

                case ItemFilter.IsNotFolder:
                    query.IsFolder = false;
                    break;

                case ItemFilter.IsPlayed:
                    query.IsPlayed = true;
                    break;

                case ItemFilter.IsResumable:
                    query.IsResumable = true;
                    break;

                case ItemFilter.IsUnplayed:
                    query.IsPlayed = false;
                    break;

                case ItemFilter.Likes:
                    query.IsLiked = true;
                    break;
                }
            }

            var result = await _channelManager.GetLatestChannelItems(query, CancellationToken.None).ConfigureAwait(false);

            return(ToOptimizedResult(result));
        }