public async Task <ActionResult <ProductDto> > GetProduct(int id) { var spec = new ProTypBranSpec(id); var products = await _productsRepo.GetEntityWithSpesification(spec); _example.GenerateMessage(); return(_mapper.Map <Product, ProductDto>(products)); }
public async Task <ActionResult <Pagination <ProductDto> > > GetProducts([FromQuery] ProductSpecParams productParams) { var spec = new ProTypBranSpec(productParams); var countSpec = new ProWitFiltFrCountSpec(productParams); var totalItems = await _productsRepo.CountAsync(countSpec); var products = await _productsRepo.ListWithSpesifcation(spec); var data = _mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductDto> >(products); return(Ok(new Pagination <ProductDto>(productParams.PageIndex, productParams.PageSize, totalItems, data))); }