コード例 #1
0
        public async Task <PaginatedResult <ListFeatureResponseDetail> > Handle(ListFeatureRequest request, CancellationToken cancellationToken)
        {
            var total = await _storeDbContext
                        .Features
                        .Where(f => f.ProductEntity.Name == request.ProductName && !f.Archived)
                        .CountAsync(cancellationToken);

            var features = await _storeDbContext
                           .Features
                           .Where(f => f.ProductEntity.Name == request.ProductName && !f.Archived)
                           .OrderBy(f => f.Name)
                           .Skip(request.PageIndex * request.PageCount)
                           .Take(request.PageCount)
                           .ToListAsync(cancellationToken);

            return(new PaginatedResult <ListFeatureResponseDetail>()
            {
                Count = features.Count,
                Total = total,
                PageIndex = request.PageIndex,
                Items = features.Select(f => new ListFeatureResponseDetail
                {
                    Description = f.Description,
                    Name = f.Name
                }).ToList()
            });
        }
コード例 #2
0
        public async Task <ActionResult <PaginatedResult <ListFeatureResponseDetail> > > List(string productName, [FromQuery] ListFeatureRequest request, CancellationToken cancellationToken = default)
        {
            request.ProductName = productName;

            var list = await _mediator.Send(request, cancellationToken);

            return(Ok(list));
        }