コード例 #1
0
        public async Task <ActionResult <Pagination <ProductToReturnDto> > > GetProducts([FromQuery] ProductSpecParams productSpecParams)
        {
            var spec       = new ProductsWithTypesandBrandsSpecification(productSpecParams);
            var countspec  = new ProductwithFiltersForCountSpecification(productSpecParams);
            var totalItems = await _productRepo.CountAsync(countspec);

            var products = await _productRepo.LisAsync(spec);

            var data = _mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductToReturnDto> >(products);

            return(Ok(new Pagination <ProductToReturnDto>(productSpecParams.PageIndex, productSpecParams.PageSize, totalItems, data)));
        }