BiosealMVCWeb.Controllers.CareersController.AjaxRecruits C# (CSharp) Method

AjaxRecruits() private method

private AjaxRecruits ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
        public ActionResult AjaxRecruits()
        {
            db = new biosealEntities();
            //获取页面索引pageIndex
            int? pageIndex = Convert.ToInt16(Request.QueryString["pageIndex"]);
            pageIndex = (pageIndex == null ? 0 : pageIndex);
            //设置每页显示条数
            int pageSize = 8;

            //查询数据和设置分页Pagination类
            var recruits = db.Recruits.OrderByDescending(i => i.Date).Skip(pageIndex.Value * pageSize).Take(pageSize).ToList();
            ViewBag.Pagination = new Pagination(pageIndex, pageSize, db.Recruits.Count());
            ViewBag.pageIndex = pageIndex;

            // 返回json数据集
            var results = new List<Recruit>();
            foreach (var item in recruits)
            {
                results.Add(item);
            }
            return Json(results);
        }