public async Task <ActionResult <Product> > GetProduct(int id) { var spec = new ProductsWithTypeAndBrand(id); //var product = await _repo.GetWithEntitySpec(spec)); var product = await _repo.GetWithEntitySpec(spec); return(_mapper.Map <Product, Product>(product)); }
public async Task <ActionResult <Pagination <Product> > > GetProducts( [FromQuery] ProductSpecPrams proPrams) { var spec = new ProductsWithTypeAndBrand(proPrams); var countSpec = new ProductWithFilteringCount(proPrams); var totalItems = await _repo.CountAsync(countSpec); var products = await _repo.ListAllAsyncWithSpec(spec); var data = _mapper .Map <IReadOnlyList <Product>, IReadOnlyList <Product> >(products); return(Ok(new Pagination <Product>(proPrams.PageIndex, proPrams.PageSize, totalItems, data))); }