Ejemplo n.º 1
0
        public Task <IPagedCollection <PlaylistDetail> > Handle(GetPlaylistListQuery request, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(GetPlaylistsList(request));
        }
Ejemplo n.º 2
0
        private async Task <IPagedCollection <PlaylistDetail> > GetPlaylistsList(GetPlaylistListQuery request)
        {
            var filter = _filterBuilder
                         .WhereTrackIdEquals(request.TrackId)
                         .WhereNameLike(request.Name).Filter;

            var playlistsFromDb = await _context
                                  .Playlists
                                  .TagWithQueryName(nameof(GetPlaylistsList))
                                  .Where(filter)
                                  .Include(e => e.PlaylistTracks)
                                  .OrderBy(request.Order, _orderBuilder)
                                  .ToPagedCollectionAsync(request.PageNumber, request.PageSize);

            var playlists = _mapper.Map <IReadOnlyList <PlaylistDetail> >(playlistsFromDb);

            return(new PagedCollection <PlaylistDetail>(
                       playlists,
                       playlistsFromDb.ItemCount,
                       playlistsFromDb.CurrentPageNumber,
                       playlistsFromDb.PageSize));
        }