public async Task <IActionResult> GetProducts([FromQuery] ProductSpecParams productParams) { var spec = new ProductsWithTypesAndBrandsSpecification(productParams); var countSpec = new ProductFilterWithCountSpecification(productParams); var totalItem = await _productRepo.CountAsync(countSpec); var products = await _productRepo.GetAllBySpecAsync(spec); var data = _mapper.Map <IEnumerable <Product>, IEnumerable <ProductToReturnDto> >(products); return(Ok(new Pagination <ProductToReturnDto> (productParams.PageIndex, productParams.PageSize, totalItem, data))); }