public ActionResult GetCommunityChDataList(string name, string quest, DateTime?bTime, DateTime?eTime, int pIndex = 1) { ViewBag.pageName = "Community"; var input = new GetCommunityInteractionInput() { IdType = (int)TempData["CommId"], UserName = name, Quest = quest, BTIme = bTime, ETime = eTime }; var pagedata = communityService.GetPagedCommunityInteractions(input); GetPageData(pagedata.TotalCount); return(PartialView("Shared/CommunityChDataList", pagedata)); }
/// <summary> /// 根据查询条件获取互动社区分页列表 /// </summary> public PagedResultDto <CommunityInteractionListDto> GetPagedCommunityInteractions(GetCommunityInteractionInput input) { var query = from comm in _communityInteractionRepository.GetAll() join user in _userAccountRepository.GetAll() on comm.UserId equals user.SysNO into cu from cui in cu.DefaultIfEmpty() select new CommunityInteractionListDto() { Id = comm.Id, UserId = comm.UserId, UserName = cui.DisplayName, ParentUserId = comm.ParentUserId, Content = comm.Content, CountUser = comm.CountUser, PublicationTime = comm.PublicationTime, CreationTime = comm.CreationTime }; //TODO:根据传入的参数添加过滤条件 query = query.Where(c => c.ParentUserId == input.IdType); if (!string.IsNullOrEmpty(input.UserName)) { query = query.Where(c => c.UserName.Contains(input.UserName)); } if (!string.IsNullOrEmpty(input.Quest)) { query = query.Where(c => c.Content.Contains(input.Quest)); } if (input.BTIme != null) { query = query.Where(c => c.PublicationTime >= input.BTIme); } if (input.ETime != null) { query = query.Where(c => c.PublicationTime <= input.ETime); } var communityInteractionCount = query.Count(); var communityInteractions = query .OrderByDescending(t => t.CreationTime) .PageBy(input) .ToList(); var communityInteractionListDtos = communityInteractions.MapTo <List <CommunityInteractionListDto> >(); return(new PagedResultDto <CommunityInteractionListDto>( communityInteractionCount, communityInteractionListDtos )); }