public async Task <ActionResult <Pagination <ProductViewModel> > > GetProductsAsync( [FromQuery] ProductResultParameters parameters) { var specification = new ProductsWithTypesAndBrandsSpecification(parameters); var countSpecification = new ProductWithFiltersForCountSpecification(parameters); var totalItems = await _productService.CountAsync(countSpecification); var products = await _productService.ListAllWithObjectsAsync(specification); var data = _mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductViewModel> >(products); return(Ok(new Pagination <ProductViewModel>(parameters.PageIndex, parameters.PageSize, totalItems, data))); }