コード例 #1
0
        /// <summary>
        /// 获取ShopEvaluation的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <ShopEvaluationListDto> > GetPagedShopEvaluations(GetShopEvaluationsInput input)
        {
            var query = _shopevaluationRepository.GetAll();
            //TODO:根据传入的参数添加过滤条件
            var shopevaluationCount = await query.CountAsync();

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

            //var shopevaluationListDtos = ObjectMapper.Map<List <ShopEvaluationListDto>>(shopevaluations);
            var shopevaluationListDtos = shopevaluations.MapTo <List <ShopEvaluationListDto> >();

            return(new PagedResultDto <ShopEvaluationListDto>(
                       shopevaluationCount,
                       shopevaluationListDtos
                       ));
        }
コード例 #2
0
        /// <summary>
        /// 获取ShopEvaluation的分页列表信息联合购买记录表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <ShopEvaluationListDto> > GetPagedShopEvaluationsByPurchaseRecord(GetShopEvaluationsInput input)
        {
            //if (input.ShopId == Guid.Empty)
            //{
            //    return new PagedResultDto<ShopEvaluationListDto>(0, new List<ShopEvaluationListDto>());
            //}
            var queryEvaluation = _shopevaluationRepository.GetAll()
                                  .Where(e => e.ShopId == input.ShopId)
                                  .WhereIf(input.Evaluation.HasValue, e => e.Evaluation == input.Evaluation);
            var queryPurchase = _purchaserecordRepository.GetAll();
            var queryWeChat   = _wechatuserRepository.GetAll();
            var query         = from e in queryEvaluation
                                join p in queryPurchase on e.PurchaseRecordId equals p.Id into queryE
                                from ep in queryE.DefaultIfEmpty()
                                join w in queryWeChat on ep.OpenId equals w.OpenId into queryP
                                from epw in queryP.DefaultIfEmpty()
                                select new ShopEvaluationListDto
            {
                Id = e.Id,
                PurchaseRecordId  = e.PurchaseRecordId,
                Specification     = ep != null ? ep.Specification : "",
                Quantity          = ep != null ? ep.Quantity : null,
                ShopId            = e.ShopId,
                OpenId            = e.OpenId,
                Evaluation        = e.Evaluation,
                IsCorrectQuantity = e.IsCorrectQuantity,
                Content           = e.Content,
                CreationTime      = e.CreationTime,
                TenantId          = e.TenantId,
                NickName          = epw != null ? epw.NickName : ""
            };

            //TODO:根据传入的参数添加过滤条件
            var shopevaluationCount = await query.CountAsync();

            var shopevaluations = await query
                                  .OrderByDescending(e => e.CreationTime)
                                  .ThenBy(input.Sorting)
                                  .PageBy(input)
                                  .ToListAsync();

            //var shopevaluationListDtos = ObjectMapper.Map<List <ShopEvaluationListDto>>(shopevaluations);
            var shopevaluationListDtos = shopevaluations.MapTo <List <ShopEvaluationListDto> >();

            return(new PagedResultDto <ShopEvaluationListDto>(
                       shopevaluationCount,
                       shopevaluationListDtos
                       ));
        }