public ActionResult GetDataList(string keyword, int type = 0, int pIndex = 1) { ViewBag.pageName = "GetDataList"; var input = new GetKonwledgeInfoInput() { FilterText = keyword, TypeId = type, SkipCount = (pIndex - 1) * PageSize, MaxResultCount = PageSize }; var pagedata = KonwledgeInfoservice.GetPagedKonwledgeInfos(input); GetPageData(pagedata.TotalCount); return(PartialView("Shared/DataList", pagedata.Items)); }
/// <summary> /// 根据查询条件获取分页列表 /// </summary> public PagedResultDto <KonwledgeInfoListDto> GetPagedKonwledgeInfos(GetKonwledgeInfoInput input) { var query = from a in _KonwledgeInfoRepository.GetAll() join b in userservice.GetAll() on a.CreatorUserId equals b.Id into bc from c in bc.DefaultIfEmpty() join d in userservice.GetAll() on a.Auditor equals d.Id into dc from e in dc.DefaultIfEmpty() join f in tageservice.GetAll() on a.TagetId equals f.Id into fc from g in fc.DefaultIfEmpty() join h in cservice.GetAll() on a.TypeId equals h.CategoryId into hc from i in hc.DefaultIfEmpty() select new KonwledgeInfoListDto { Id = a.Id, Title = a.Title, Content = a.Content, ImageUrl = a.ImageUrl, CreationTime = a.CreationTime, CreatorUserName = c.DisplayName, Enabled = a.Enabled, AuditorName = e.DisplayName, Stauts = a.Stauts, ReviewedDate = a.ReviewedDate, CollectionCount = a.CollectionCount, ReadingCount = a.ReadingCount, TypeId = a.TypeId, TagetName = g.Name, TagetId = a.TagetId, TypeName = i.CourseCategoryName }; query = query.WhereIf(!string.IsNullOrEmpty(input.FilterText), t => t.Title.Contains(input.FilterText)). WhereIf(input.TagetId > 0, t => t.TagetId == input.TagetId). WhereIf(input.TypeId > 0, t => t.TypeId == input.TypeId); //TODO:根据传入的参数添加过滤条件 var KonwledgeInfos = query.OrderByDescending(t => t.CreationTime).PageBy(input).ToList(); var KonwledgeInfoListDto = KonwledgeInfos.MapTo <List <KonwledgeInfoListDto> >(); return(new PagedResultDto <KonwledgeInfoListDto>(query.Count(), KonwledgeInfoListDto)); }