예제 #1
0
        public IQueryable <Articel> GetArticelList(ArticleInfoSearch articleInfoSearch)
        {
            IQueryable <Articel> ArticleInfoList = this.DbSession.ArticelDAL.LoadEntity(a => a.DelFlag == 0);

            if (!string.IsNullOrEmpty(articleInfoSearch.ArticelClassID))
            {
                int articleClassId = Convert.ToInt32(articleInfoSearch.ArticelClassID);
                ArticleInfoList = from a in ArticleInfoList
                                  from b in a.ArticelClass
                                  where b.ID == articleClassId
                                  select a;
            }
            if (!string.IsNullOrEmpty(articleInfoSearch.ArticeTitle))
            {
                ArticleInfoList = ArticleInfoList.Where(a => a.Title.Contains(articleInfoSearch.ArticeTitle));
            }
            if (!string.IsNullOrEmpty(articleInfoSearch.ArticelAuthor))
            {
                ArticleInfoList = ArticleInfoList.Where(a => a.Author.Contains(articleInfoSearch.ArticelAuthor));
            }
            if (!string.IsNullOrEmpty(articleInfoSearch.ToDatepicker) && !string.IsNullOrEmpty(articleInfoSearch.FormDatepicker))
            {
                DateTime fromDate = Convert.ToDateTime(articleInfoSearch.FormDatepicker);
                DateTime toDate   = Convert.ToDateTime(articleInfoSearch.ToDatepicker);
                ArticleInfoList = ArticleInfoList.Where(a => a.AddDate >= fromDate && a.AddDate <= toDate);
            }
            articleInfoSearch.TotalCount = ArticleInfoList.Count();
            IQueryable <Articel> temp = ArticleInfoList.OrderBy <Articel, int>(a => a.ID).Skip <Articel>((articleInfoSearch.PageIndex - 1) * articleInfoSearch.PageSize).Take <Articel>(articleInfoSearch.PageSize);

            return(temp);
        }
예제 #2
0
        /// <summary>
        /// 获取列表信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetArticelInfo()
        {
            int pageIndex  = Request["page"] == null ? 1 : Convert.ToInt32(Request["page"]);
            int pageSize   = Request["rows"] == null ? 5 : Convert.ToInt32(Request["rows"]);
            int totalCount = 0;
            ArticleInfoSearch articleInfoSearch = new ArticleInfoSearch()
            {
                ArticelAuthor  = Request["txtArticelAuthor"],
                ArticelClassID = Request["articelClassId"],
                ArticeTitle    = Request["txtArticeTitle"],
                FormDatepicker = Request["formDatepicker"],
                ToDatepicker   = Request["toDatepicker"],
                PageIndex      = pageIndex,
                PageSize       = pageSize,
                TotalCount     = totalCount
            };
            IQueryable <Articel> list = ArticelBLL.GetArticelList(articleInfoSearch);
            var temp = from a in list
                       select new { ID = a.ID, Title = a.Title, Author = a.Author, Origin = a.Origin, AddDate = a.AddDate, ClassName = from b in a.ArticelClass select b.ClassName };

            return(Json(new { total = articleInfoSearch.TotalCount, rows = temp }, JsonRequestBehavior.AllowGet));
        }