예제 #1
0
        public async Task <ActionResult <ProductToReturnDTO> > GetProduct(int id)
        {
            var spec = new ProductWithSpecs(id);
            var data = await _productRepository.GetEntityWithSpec(spec);

            return(_mapper.Map <Product, ProductToReturnDTO>(data));
        }
예제 #2
0
        public async Task <ActionResult <Pagination <Product> > > GetProducts([FromQuery] ProductSpecParams productSpecParams)
        {
            var spec       = new ProductWithSpecs(productSpecParams);
            var countSpec  = new ProductsWithFiltersForCountSpec(productSpecParams);
            var totalItems = await _productRepository.CountAsync(spec);

            var products = await _productRepository.ListAsync(spec);

            var data = _mapper.Map <IReadOnlyList <Product>, IReadOnlyList <ProductToReturnDTO> >(products);

            // return Ok(new Pagination<ProductToReturnDTO>(productSpecParams.PageIndex,productSpecParams.Pagesize,totalItems,data));
            return(Ok(data));
        }