示例#1
0
        public async Task <ActionResult <Pagination <ProductToReturnDto> > > GetProducts([FromQuery] ProductsSpecParams prodParams)
        {
            var spec       = new ProductsWithTypesAndBrandsSpecification(prodParams);
            var countSpect = new ProductsWithFiltersForCountSpecification(prodParams);

            var totalItems = await _productRepo.ContAsync(countSpect);

            var Fullproducts = await _productRepo.GetEntityListWithSpecAsync(spec);

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

            return(Ok(new Pagination <ProductToReturnDto> {
                Count = totalItems,
                Data = data,
                PageIndex = prodParams.PageIndex,
                PageSize = prodParams.PageSize
            }));
        }