Exemplo n.º 1
0
        public async Task <PagedResponse <FoundGenreDTO> > Handle(SearchGenreQuery request, CancellationToken cancellationToken)
        {
            GenreSearchCondition searchCondition = new GenreSearchCondition()
            {
                Name          = GetFilterValues(request.SearchCondition.Name),
                Page          = request.SearchCondition.Page,
                PageSize      = request.SearchCondition.PageSize,
                SortDirection = request.SearchCondition.SortDirection,
                SortProperty  = request.SearchCondition.SortProperty
            };

            var sortProperty = GetSortProperty(searchCondition.SortProperty);
            IReadOnlyCollection <Genre> foundGenre = await genreService.FindAsync(searchCondition, sortProperty);

            FoundGenreDTO[] mappedGenre = foundGenre.Select(MapToFoundGenreDTO).ToArray();
            var             totalCount  = await genreService.CountAsync(searchCondition);

            return(new PagedResponse <FoundGenreDTO>
            {
                Items = mappedGenre,
                TotalCount = totalCount
            });
        }