コード例 #1
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #2
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #3
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #4
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #5
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #6
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #7
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #8
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #9
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #10
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }
コード例 #11
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #12
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #13
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
        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;
        }
コード例 #14
0
ファイル: ArticleServiceImpl.cs プロジェクト: the404/yqblog
 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;
 }