public Pager GetArchivesArticlePaging(Pager pager, int tid, int year, int month, int day, int iscommend, string order = "desc") { var query = GetVArticles(tid, 0, 0, iscommend).Where(m => m.createdate.Year == year); if (month > 0) { query = query.Where(m => m.createdate.Month == month); } if (day > 0) { query = query.Where(m => m.createdate.Day == day); } pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetTagArticlePaging(Pager pager, int tid, string tag, int iscommend, string order = "desc") { var query = GetVArticles(tid, 0, 0, iscommend).Where(m => ("," + m.tags + ",").Contains("," + tag + ",")); pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetReplyPaging(Pager pager, int tid, string cids, int layer, string sort = "", string order = "desc", string user = "") { var query = GetArticlesViaLang(0); if (tid > 0) { query = query.Where(m => m.typeid == tid);} if (cids != "") { var listids = new List<string>(cids.Split(',')).ConvertAll(int.Parse); query = query.Where(m => listids.Contains(m.cateid)); } if (user != "") { query = query.Where(m => m.userid == 1).Where(m => m.username == user);} query = query.Where(m => m.layer == layer); switch (sort) { case "normal": query = query.Where(m => m.status == 1); break; case "draft": query = query.Where(m => m.status == 2); break; case "istop": query = query.Where(m => m.istop == 1); break; case "iscommend": query = query.Where(m => m.iscommend == 1); break; } pager.Amount = query.Count(); query = order == "desc" ? query.OrderByDescending(m => m.id) : query.OrderBy(m => m.id); query = query.Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetNotesPagingByOrderId(Pager pager, int cid, long orderid, string order = "asc") { var query = GetVArticles(0, cid, 0, 0, string.Empty); var queryTmp = order == "asc" ? query.Where(m => m.orderid <= orderid) : query.Where(m => m.orderid >= orderid); pager.Amount = queryTmp.Count(); pager.PageNo = pager.PageCount > 0 ? pager.PageCount : 1; pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetReplyPaging(Pager pager, int tid, int cid, string sort = "", string order = "desc", long user = 0) { var query = GetReplyArticles(tid, cid, 0,user); switch (sort) { case "normal": query = query.Where(m => m.status == 1); break; case "draft": query = query.Where(m => m.status == 2); break; case "istop": query = query.Where(m => m.istop == 1); break; case "iscommend": query = query.Where(m => m.iscommend == 1); break; } pager.Amount = query.Count(); query = order == "desc" ? query.OrderByDescending(m => m.id) : query.OrderBy(m => m.id); query = query.Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetFloorNotePaging(Pager pager, int cid, string order = "asc") { var queryAll = _entity.blog_article.Where(m => m.cateid == cid); var query = queryAll.Where(m => m.status == 1); pager.Amount = query.Count(); var queryPage = (order == "asc" ? query.OrderBy(m => m.istop).ThenBy(m => m.id) : query.OrderBy(m => m.istop).ThenByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = ConvertToFloorArticle(queryAll, queryPage); return pager; }
public Pager GetKeySearchPaging(Pager pager, int tid, string key, int iscommend, string order = "desc") { var query = GetVArticles(tid, 0, 0, iscommend).Where(m => (m.tags + m.title + m.summary).Contains(key) || m.content.Contains(key)); pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetCommentPaging(Pager pager, long articleid, string order = "asc") { IQueryable<blog_article> query = _entity.blog_article; if (articleid > 0) { query = query.Where(m =>m.layer==1 && m.articleid == articleid); } pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize*GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetFloorCommentPagingByOrderId(Pager pager, long articleid, long orderid, string order = "asc") { IQueryable<blog_article> queryAll = _entity.blog_article; if (articleid > 0) { queryAll = queryAll.Where(m => m.layer == 1 && m.articleid == articleid); } var query = queryAll.Where(m => m.status == 1); var queryTmp = order == "asc" ? query.Where(m => m.orderid <= orderid) : query.Where(m => m.orderid >= orderid); pager.Amount = queryTmp.Count(); pager.PageNo = pager.PageCount > 0 ? pager.PageCount : 1; pager.Amount = query.Count(); var queryPage = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = ConvertToFloorArticle(queryAll, queryPage); return pager; }
public int GetCommentPageNo(int pagesize, long parentid, int floor, int ordertype = 1) { var pager = new Pager {PageSize = pagesize}; var query = _entity.blog_article.Where(m => m.parentid == parentid); query = ordertype == 1 ? query.Where(m => m.orderid <= floor) : query.Where(m => m.orderid >= floor); pager.Amount = query.Count(); return pager.PageCount; }
public Pager GetAuthorArticlePaging(Pager pager, int tid, string user, int iscommend, string order = "desc") { var query = GetVArticles(tid, 0, 0, iscommend).Where(m => m.username == user && m.userid > 0); pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetArticlePaging(Pager pager, int tid, int cid,string cids, int iscommend = 0, string order = "desc") { var query = GetVArticles(tid, cids, 0, iscommend); pager.Amount = query.Count(); query = (order == "asc" ? query.OrderBy(m => (m.cateid == cid && m.istop == 1) ? 1 : 2).ThenBy(m => m.id) : query.OrderBy(m => (m.cateid == cid && m.istop == 1) ? 1 : 2).ThenByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); pager.Entity = query; return pager; }
public Pager GetArticlePaging(Pager pager, int tid, int cid, int iscommend = 0,string field="",long user=0,string order="desc",string articleListType="index") { var query = GetVArticles(tid, cid, 0, iscommend, "",user); pager.Amount = query.Count(); if (field != "") { switch (field) { case "lastpost": query = (cid > 0 ? query.OrderBy(m => m.lastreplydate) : query.OrderByDescending(m => m.lastreplydate)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); break; } } else { switch (articleListType) { case "category": query = (order == "asc" ? query.OrderBy(m => m.istop).ThenBy(m => m.id) : query.OrderBy(m => m.istop).ThenByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); break; case "index": query = (order == "asc" ? query.OrderBy(m => m.isindextop).ThenBy(m => m.id) : query.OrderBy(m => m.isindextop).ThenByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); break; default: query = (order == "asc" ? query.OrderBy(m => m.id) : query.OrderByDescending(m => m.id)).Skip(pager.PageSize * GetPageNo(pager.PageNo)).Take(pager.PageSize); break; } } pager.Entity = query; return pager; }
public int GetArticlePageNo(int pagesize, int cid, int floor, int ordertype = 1) { var pager = new Pager {PageSize = pagesize}; var query = _entity.blog_article.Where(m => m.cateid == cid).Where(m => m.layer ==0); query = ordertype == 1 ? query.Where(m => m.orderid <= floor) : query.Where(m => m.orderid >= floor); pager.Amount = query.Count(); return pager.PageCount; }