Esempio n. 1
0
        /// <summary>
        /// 获取ShopProduct的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <ShopProductListDto> > GetPagedShopProducts(GetShopProductsInput input)
        {
            var query = _shopproductRepository.GetAll();
            //TODO:根据传入的参数添加过滤条件
            var shopproductCount = await query.CountAsync();

            var shopproducts = await query
                               .OrderBy(input.Sorting)
                               .PageBy(input)
                               .ToListAsync();

            //var shopproductListDtos = ObjectMapper.Map<List <ShopProductListDto>>(shopproducts);
            var shopproductListDtos = shopproducts.MapTo <List <ShopProductListDto> >();

            return(new PagedResultDto <ShopProductListDto>(
                       shopproductCount,
                       shopproductListDtos
                       ));
        }
 public Task <PagedResultDto <ShopProductListDto> > GetPagedShopProducts(GetShopProductsInput input)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 3
0
        /// <summary>
        /// 获取ShopProduct的分页列表信息连接Product表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <ShopProductListDto> > GetPagedShopProductsReferProducts(GetShopProductsInput input)
        {
            var querySP = _shopproductRepository.GetAll()
                          .Where(sp => sp.ShopId == input.ShopId);
            var queryP = _productRepository.GetAll()
                         .Where(p => p.IsRare == true && p.IsAction == true);
            var query = from sp in querySP
                        join p in queryP on sp.ProductId equals p.Id
                        select new ShopProductListDto
            {
                Id            = sp.Id,
                ProductId     = sp.ProductId,
                ShopId        = sp.ShopId,
                Specification = p.Specification,
                Type          = p.Type,
                Price         = p.Price,
                PackageCode   = p.PackageCode,
                BarCode       = p.BarCode,
                PhotoUrl      = p.PhotoUrl
            };
            //TODO:根据传入的参数添加过滤条件
            var shopproductCount = await query.CountAsync();

            var shopproducts = await query
                               .OrderBy(sp => sp.Specification)
                               .ThenBy(input.Sorting)
                               .PageBy(input)
                               .ToListAsync();

            //var shopproductListDtos = ObjectMapper.Map<List <ShopProductListDto>>(shopproducts);
            var shopproductListDtos = shopproducts.MapTo <List <ShopProductListDto> >();

            return(new PagedResultDto <ShopProductListDto>(
                       shopproductCount,
                       shopproductListDtos
                       ));
        }