public ActionResult TopicManager() { ItcastEntities db = new ItcastEntities(); //分页显示数据 int pageIndex; int pageSize = 10; if (!int.TryParse(Request.QueryString["pageIndex"], out pageIndex)) { pageIndex = 1; } BLL.TopicManager examTopicManager = new BLL.TopicManager(); //获得最大页数 int pageCount = examTopicManager.GetpageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; PageIndex = pageIndex; PageSize = pageSize; PageCount = pageCount; //获得数据集合 var ExamTopic = examTopicManager.GetTopicInfo(PageIndex, PageSize); ViewData.Model = ExamTopic; ViewData["PageIndex"] = PageIndex; ViewData["PageCount"] = PageCount; return(View()); }
public static DbContext CreateDbContext() { DbContext DbContext = (DbContext)CallContext.GetData("dbContext"); if (DbContext == null) { DbContext = new ItcastEntities(); CallContext.SetData("dbContext", DbContext); } return(DbContext); }