Beispiel #1
0
        /// <summary>
        /// 查询我的带看
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="cancellationToken">验证</param>
        /// <returns></returns>
        public virtual async Task <PagingResponseMessage <AboutLookResponse> > SelectMyCustomer(string id, MyAboutLookCondition condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            var reponse = new PagingResponseMessage <AboutLookResponse>();

            var list = new List <AboutLookResponse>();
            var q    = _iaboutLookStore.AboutLookAll().Where(x => !x.IsDeleted).Where(x => x.UserId == id);

            reponse.TotalCount = await q.CountAsync();

            if (condition != null)
            {
                if (condition.mark == 1)
                {
                    q = q.Where(x => x.AboutState == AboutLookState.WaitLook);
                }
                else if (condition.mark == 2)
                {
                    q = q.Where(x => x.AboutState == AboutLookState.WaitDeal);
                }
                else if (condition.mark == 3)
                {
                    q = q.Where(x => x.AboutState == AboutLookState.EndDeal);
                }
                else if (condition.mark == 4)
                {
                    q = q.Where(x => x.AboutState == AboutLookState.Cancel);
                }
            }
            q = q.OrderByDescending(x => x.AboutTime).Skip(condition.pageIndex * condition.pageSize).Take(condition.pageSize);
            var result = await q.ToListAsync();

            list.AddRange(_mapper.Map <List <AboutLookResponse> >(result));

            reponse.PageIndex = condition.pageIndex;
            reponse.PageSize  = condition.pageSize;
            reponse.Extension = list;
            return(reponse);
        }
Beispiel #2
0
        public async Task <PagingResponseMessage <AboutLookResponse> > GetMyAboutLook(UserInfo user, [FromBody] MyAboutLookCondition condition)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})发起请求根据条件获取我的带看信息(GetMyAboutLook):\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));

            var response = new PagingResponseMessage <AboutLookResponse>();

            if (condition == null)
            {
                var error  = "";
                var errors = ModelState.Values.ToList();
                foreach (var item in errors)
                {
                    foreach (var e in item.Errors)
                    {
                        error += e.ErrorMessage + "  ";
                    }
                }
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = error;
                Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})根据条件获取我的带看信息(GetMyAboutLook)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
                return(response);
            }
            try
            {
                response = await _aboutLookManager.SelectMyCustomer(user.Id, condition, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})根据条件获取我的带看信息(GetMyAboutLook)请求失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            }
            return(response);
        }