Example #1
0
        /// <summary>
        /// 订单分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <OrderDto> > GetPagedAsync(OrderSearchPagedDto search)
        {
            Expression <Func <Order, bool> > whereCondition = x => true;

            if (search.Id > 0)
            {
                whereCondition = whereCondition.And(x => x.Id == search.Id);
            }
            var pagedEntity = await _orderRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = _mapper.Map <PageModelDto <OrderDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合订单状态信息
                var rpcReuslt = await _maintRpc.GetDictAsync(DictConsts.OrderStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusChangesReason = dicts.FirstOrDefault(d => d.Name == x.StatusCode.ToSafeString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }
Example #2
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <ProductDto> > GetPagedAsync(ProductSearchPagedDto search)
        {
            Expression <Func <Product, bool> > whereCondition = x => true;

            if (!search.Id.IsNullOrEmpty())
            {
                whereCondition = whereCondition.And(x => x.Id == search.Id.ToLong());
            }
            var pagedEntity = await _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = _mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(DictConsts.ProdunctStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusDescription = dicts.FirstOrDefault(d => d.Name == x.StatusCode.ToString())?.Value;
                    });
                }
            }
            return(pagedDto);
        }
Example #3
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <ProductDto> > GetPagedAsync(ProductSearchPagedDto search)
        {
            var whereCondition = ExpressionCreator
                                 .New <Product>()
                                 .AndIf(search.Id > 0, x => x.Id == search.Id);

            var pagedEntity = await _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.Id);

            var pagedDto = Mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(Consts.ProdunctStatusId);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusDescription = dicts.FirstOrDefault(d => d.Value == x.StatusCode.ToString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }