/// <summary>
        /// 获取产品列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>

        public override async Task <PagedResultDto <ProductDto> > GetListAsync(GetProductListDto input)
        {
            if (input.Sorting.IsNullOrWhiteSpace())
            {
                input.Sorting = nameof(Product.Sort);
            }

            var products = await _productRepository.GetListAsync(
                input.SkipCount,
                input.MaxResultCount,
                input.Sorting,
                input.Filter
                );

            var totalCount = _productRepository.Where(
                product => String.IsNullOrEmpty(input.Filter) || product.Name.Contains(input.Filter)
                ).Count();

            return(new PagedResultDto <ProductDto>(
                       totalCount,
                       ObjectMapper.Map <List <Product>, List <ProductDto> >(products)
                       ));
        }
Beispiel #2
0
        public async Task <PagedResultDto <ServiceDto> > GetListAsync(GetProductListDto input)
        {
            //await NormalizeMaxResultCountAsync(input);
            var services = await _serviceRepository

                           /*.GetListAsync(
                            * input.SkipCount,
                            * input.MaxResultCount,
                            * input.Sorting,
                            * input.Filter
                            *
                            * );*/
                           .OrderBy(input.Sorting ?? nameof(Service.Name))
                           .Skip(input.SkipCount)
                           .Take(input.MaxResultCount)
                           .ToListAsync();

            var totalCount = await _serviceRepository.GetCountAsync();

            var dtos = ObjectMapper.Map <List <Service>, List <ServiceDto> >(services);

            return(new PagedResultDto <ServiceDto>(totalCount, dtos));
        }
Beispiel #3
0
 public Task <PagedResultDto <ProductDto> > GetListAsync(GetProductListDto input)
 {
     return(_service.GetListAsync(input));
 }