public async Task <PagingResponseMessage <UpdateRecordListResponse> > GetListAsync(UpdateRecordListCondition condition, CancellationToken cancellationToken = default(CancellationToken)) { PagingResponseMessage <UpdateRecordListResponse> pagingResponse = new PagingResponseMessage <UpdateRecordListResponse>(); if (condition == null) { throw new ArgumentNullException(nameof(UpdateRecordListCondition)); } var q = Store.GetDetail().Where(a => !a.IsDeleted); if (condition.ContentTypes?.Count > 0) { q = q.Where(a => condition.ContentTypes.Contains(a.ContentType)); } if (condition.ContentIds?.Count > 0) { q = q.Where(a => condition.ContentIds.Contains(a.ContentId)); } if (condition.ExamineStatus?.Count > 0) { q = q.Where(a => condition.ExamineStatus.Contains(a.ExamineStatus)); } if (!string.IsNullOrEmpty(condition.KeyWord)) { q = q.Where(a => a.Title.Contains(condition.KeyWord) || a.Content.Contains(condition.KeyWord)); } if (condition.UpdateTypes?.Count > 0) { q = q.Where(a => condition.UpdateTypes.Contains(a.UpdateType)); } if (!string.IsNullOrEmpty(condition.UserId)) { q = q.Where(a => a.UserId == condition.UserId); } if (condition.IsCurrent != null) { q = q.Where(a => a.IsCurrent == condition.IsCurrent); } if (!string.IsNullOrEmpty(condition.AreaCode)) { q = q.Where(a => a.AreaDefine.Code == condition.AreaCode); } if (!string.IsNullOrEmpty(condition.DistrictCode)) { q = q.Where(a => a.DistrictDefine.Code == condition.DistrictCode); } if (!string.IsNullOrEmpty(condition.CityCode)) { q = q.Where(a => a.CityDefine.Code == condition.CityCode); } 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); }
public async Task <PagingResponseMessage <UpdateRecordListResponse> > GetUpdateRecordList(UserInfo user, [FromBody] UpdateRecordListCondition condition) { PagingResponseMessage <UpdateRecordListResponse> response = new PagingResponseMessage <UpdateRecordListResponse>(); if (!ModelState.IsValid) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})获取房源动态列表(GetUpdateRecordList)报错:{response.Message ?? ""},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : "")); } try { return(await _updateRecordManager.GetListAsync(condition, HttpContext.RequestAborted)); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})获取房源动态列表(GetUpdateRecordList)报错:{e.ToString()},\r\n请求参数为:\r\n" + (condition != null ? JsonHelper.ToJson(condition) : "")); } return(response); }