示例#1
0
        public async Task <IActionResult> GetBrands()
        {
            var spec   = new BrandsSpecification();
            var brands = await _brandRepo.GetAllBySpecAsync(spec);

            return(Ok(brands));
        }
示例#2
0
        public async Task <IActionResult> GetTypes()
        {
            var spec  = new TypesSpecification();
            var types = await _typeRepo.GetAllBySpecAsync(spec);

            return(Ok(types));
        }
示例#3
0
        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)));
        }