コード例 #1
0
        public async Task <PagingResponseMessage <UpdateRecordListResponse> > GetFollowListAsync(string userId, UpdateRecordFollowListCondition condition, CancellationToken cancellationToken = default(CancellationToken))
        {
            PagingResponseMessage <UpdateRecordListResponse> pagingResponse = new PagingResponseMessage <UpdateRecordListResponse>();

            var q = Store.GetFollowDetail(userId).Where(a => !a.IsDeleted && a.ExamineStatus == Models.ExamineStatusEnum.Approved);

            string fr = ApplicationCore.ApplicationContext.Current.FileServerRoot;

            fr = (fr ?? "").TrimEnd('/');

            pagingResponse.TotalCount = await q.CountAsync(cancellationToken);

            var qlist = await q.OrderByDescending(a => a.SubmitTime).Skip(condition.PageIndex * condition.PageSize).Take(condition.PageSize).ToListAsync(cancellationToken);

            var resulte = qlist.Select(a => new UpdateRecordListResponse
            {
                ContentId     = a.ContentId,
                UserName      = a.UserName,
                Id            = a.Id,
                Icon          = string.IsNullOrEmpty(a.Icon) ? "" : fr + "/" + a.Icon.TrimStart('/'),
                SubmitTime    = a.SubmitTime,
                ContentType   = a.ContentType,
                ExamineStatus = a.ExamineStatus,
                Title         = a.Title,
                UpdateTime    = a.UpdateTime,
                UpdateType    = a.UpdateType,
                IsCurrent     = a.IsCurrent,
                UserId        = a.UserId,
                Ext1          = a.Ext1,
                Ext2          = a.Ext2,
                Ext3          = a.Ext3,
                Ext4          = a.Ext4,
                Ext5          = a.Ext5,
                Ext6          = a.Ext6,
                Ext7          = a.Ext7,
                Ext8          = a.Ext8,
                BuildingName  = a.BuildingName,
                AreaFullName  = (a.CityDefine != null && !string.IsNullOrEmpty(a.CityDefine.Name) ? a.CityDefine.Name + "-" : "") +
                                (a.DistrictDefine != null && !string.IsNullOrEmpty(a.DistrictDefine.Name) ? a.DistrictDefine.Name + "-" : "") +
                                (a.AreaDefine != null && !string.IsNullOrEmpty(a.AreaDefine.Name) ? a.AreaDefine.Name : "")
            });

            pagingResponse.PageIndex = condition.PageIndex;
            pagingResponse.PageSize  = condition.PageSize;
            pagingResponse.Extension = resulte.ToList();
            return(pagingResponse);
        }
コード例 #2
0
        public async Task <PagingResponseMessage <UpdateRecordListResponse> > GetUpdateRecordFollowList(UserInfo user, [FromBody] UpdateRecordFollowListCondition condition)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增房源动态列表(GetUpdateRecordFollowList):\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));

            PagingResponseMessage <UpdateRecordListResponse> response = new PagingResponseMessage <UpdateRecordListResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增房源动态列表(GetUpdateRecordFollowList)模型验证失败:{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
                return(response);
            }
            try
            {
                return(await _updateRecordManager.GetFollowListAsync(user.Id, condition, HttpContext.RequestAborted));
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增房源动态列表(GetUpdateRecordFollowList)报错:{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : ""));
            }
            return(response);
        }