public ResponseInfoModel Contentlist([FromUri] GetPublicityContentListInput input) { ResponseInfoModel json = new ResponseInfoModel() { Success = 1, Result = new object() }; try { int pageSize = _systemConfigurationService.GetPageSize(); int limit = pageSize; int offset = pageSize * (input.PageIndex - 1); int total; var outputList = _PublicityContentService.GetContentList(limit, offset, out total, input); json.Result = new PagingInfo() { totalCount = total, pageCount = (int)Math.Ceiling((decimal)total / pageSize), pageSize = pageSize, list = outputList }; } catch (Exception e) { DisposeUserFriendlyException(e, ref json, "api/publicity/contentlist", LocalizationConst.QueryFail); } return(json); }
public List <GetPublicityContentListOutput> GetContentList(int limit, int offset, out int total, GetPublicityContentListInput input) { string keyword = (input.Keyword ?? "").Trim(); var temp = from a in db.PublicityContents join b in db.ArticleAttaches on a.AttachGuid equals b.ArticleGuid into t1 from tt1 in t1.DefaultIfEmpty() join c in db.PublicityCategories on a.PublicityCategoryID equals c.ID where (string.IsNullOrEmpty(keyword) || a.PublicityName.Contains(keyword)) && c.PublicityTypesID == input.PublicityTypesID && (input.PublicityCateID == 0 || a.PublicityCategoryID == input.PublicityCateID) orderby a.OrderID, a.PublishTime descending select new { a, tt1.AttachUrl, c.PublicityCategoryName }; total = temp.Count(); var list = temp.Skip(offset).Take(limit).Select(s => new GetPublicityContentListOutput() { AttachUrl = s.AttachUrl ?? "", ID = s.a.ID, NavType = s.a.NavType, NavUrl = s.a.NavUrl ?? "", OrderID = s.a.OrderID, PublicityCategoryName = s.PublicityCategoryName ?? "", PublicityCategoryID = s.a.PublicityCategoryID, Remark = s.a.Remark ?? "", PublishTime = s.a.PublishTime, PublicityName = s.a.PublicityName ?? "", ExpiredTime = s.a.ExpiredTime, ExpiredType = s.a.ExpiredType, ShowType = s.a.ShowType, PublishType = s.a.PublishType }).AsNoTracking().ToList(); return(list); }