Ejemplo n.º 1
0
 public ViewResult QueryString(int pageIndex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(pageIndex, 5));
     }
 }
Ejemplo n.º 2
0
 public ActionResult AjaxPartialLoading(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 8));
     }
 }
Ejemplo n.º 3
0
 public ViewResult Basic(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 4
0
 public ActionResult ApplyCSS(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(new PagedList<string>(new string[0], id, 1, 80));
     }
 }
Ejemplo n.º 5
0
 public ActionResult CustomRouting(int pageindex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageindex, 5));
     }
 }
Ejemplo n.º 6
0
 public ActionResult CustomRouting(int pageindex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(pageindex, 5));
     }
 }
Ejemplo n.º 7
0
 public ViewResult Basic(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 8
0
        //public ViewResult HtmlSorting(string field, string order, int pageIndex = 1)
        //{
        //    using (var db = new DataContext())
        //    {
        //        string sql = string.Format("Select * from articles order by {0} {1}",field,order);
        //        return View(db.Database.SqlQuery<Article>(sql).ToPagedList(pageIndex,5));
        //    }
        //}

        public ViewResult QueryString(int pageIndex = 1)
        {
            using (var db = new DataContext())
            {
                return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, 5));
            }
        }
Ejemplo n.º 9
0
 public ActionResult PageIndexBox(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 10
0
 public ActionResult PageIndexBox(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 11
0
 public ActionResult AjaxPaging(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 8);
         if (Request.IsAjaxRequest())
             return PartialView("_ArticleList", model);
         return View(model);
     }
 }
Ejemplo n.º 12
0
 public ActionResult AjaxLoading(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 8);
         if (Request.IsAjaxRequest())
         {
             System.Threading.Thread.Sleep(2000);
             return PartialView("_AjaxLoading", model);
         }
         return View(model);
     }
 }
Ejemplo n.º 13
0
 public ActionResult AjaxEvents(int id = 1)
 {
     using (var db = new DataContext())
     {
         if (id == 2)
         {
             Response.StatusCode = 500;
             return Content("测试用的服务器端错误信息");
         }
         //throw new ApplicationException("测试用的服务器端错误信息");
         var model = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 8);
         if (Request.IsAjaxRequest())
             return PartialView("_AjaxEvents", model);
         return View(model);
     }
 }
Ejemplo n.º 14
0
 public ActionResult JavascriptApiHtml(int id = 1, int pageIndex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 15
0
 private ActionResult ajaxSearchPostResult(string title,string author,string source, int id = 1)
 {
     using (var db = new DataContext())
     {
         var qry = db.Articles.AsQueryable();
         if (!string.IsNullOrWhiteSpace(title))
             qry = qry.Where(a => a.Title.Contains(title));
         if (!string.IsNullOrWhiteSpace(author))
             qry = qry.Where(a => a.Author.Contains(author));
         if (!string.IsNullOrWhiteSpace(source))
             qry = qry.Where(a => a.Source.Contains(source));
         var model = qry.OrderByDescending(a => a.PubDate).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
             return PartialView("_AjaxSearchPost", model);
         return View(model);
     }
 }
Ejemplo n.º 16
0
 public ActionResult AjaxDegradation(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
             return PartialView("_Degradation", model);
         return View(model);
     }
 }
Ejemplo n.º 17
0
 public ActionResult MultipleAjaxPagers(int id = 1,int pageIndex=1)
 {
     using (var db = new DataContext())
     {
         var pageSize = 5;
         var model = new CompositeArticles();
         model.ArticleList1 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize);
         model.ArticleList2 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize);
         return View(model);
     }
 }
Ejemplo n.º 18
0
 public ActionResult AjaxPagers(int id = 1, int pageIndex = 1, int page = 1)
 {
     using (var db = new DataContext())
     {
         const int pageSize = 5;
         if (Request.IsAjaxRequest())
         {
             var target = Request.QueryString["target"];
             if (target == "articles")
             {
                 return PartialView("_AjaxArticles1",
                     db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize));
             }
             if (target == "articles2")
             {
                 return PartialView("_AjaxArticles2",
                     db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize));
             }
             return PartialView("_AjaxArticles3",
                 db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(page, pageSize));
         }
         var model = new CompositeArticles
         {
             ArticleList1 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize),
             ArticleList2 =
                 db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageIndex, pageSize),
             ArticleList3 = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(page, pageSize)
         };
         return View(model);
     }
 }
Ejemplo n.º 19
0
 public ActionResult JavascriptApiHtml(int id = 1, int pageIndex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 20
0
 public ActionResult LoadByAjax(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
         {
             return PartialView("_LoadByAjax", model);
         }
         return View();
     }
 }
Ejemplo n.º 21
0
 public ActionResult PageSize(int pagesize = 10, int pageindex = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(pageindex, pagesize));
     }
 }
Ejemplo n.º 22
0
 public ActionResult ContentPaging(int id=1)
 {
     using (var db = new DataContext())
     {
         var art = db.Articles.SingleOrDefault(a => a.ID == 25); //获取演示用的长文章
         if (art != null)
         {
             return View(new PagedArticle(art, id));
         }
         return new HttpNotFoundResult("找不到指定的文章");
     }
 }
Ejemplo n.º 23
0
 public ActionResult JavascriptApiAjax(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
             return PartialView("_OrderList", model);
         return View(model);
     }
 }
Ejemplo n.º 24
0
 public ActionResult CustomizeAjaxPager(int id = 1)
 {
     using (var db = new DataContext())
     {
         var model = db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
             return PartialView("_AjaxPagerHidden", model);
         return View(model);
     }
 }
Ejemplo n.º 25
0
 public ActionResult CustomizeHtmlPager(int id = 1)
 {
     using (var db = new DataContext())
     {
         return View(db.Orders.OrderBy(o=>o.OrderId).ToPagedList(id, 5));
     }
 }
Ejemplo n.º 26
0
        public ActionResult MultipleMvcPagers(int id = 1,int pageIndex=1)
        {
            using (var db = new DataContext())
            {
                var pageSize = 5;
                List<Tuple<int,string,string>> usrs=new List<Tuple<int, string, string>>();
                var startIndex = (pageIndex - 1) * pageSize + 1;
                for (int i = startIndex; i < pageSize + startIndex; i++)
                {
                    usrs.Add(new Tuple<int, string, string>(i, "会员" + i, "住址" + i));
                }

                CustomViewModel model=new CustomViewModel();
                model.Users = new PagedList<Tuple<int, string, string>>(usrs, pageIndex, pageSize, 89);
                model.Articles = db.Articles.OrderByDescending(a => a.PubDate).ToPagedList(id, pageSize);
                return View(model);
            }
        }
Ejemplo n.º 27
0
 public ActionResult MultipleAjaxPagers(int id = 1,int pageIndex=1)
 {
     using (var db = new DataContext())
     {
         var pageSize = 5;
         var model = new Tuple<PagedList<Order>, PagedList<Order>>(
             db.Orders.OrderBy(o => o.OrderId).ToPagedList(pageIndex, pageSize),
             db.Orders.OrderBy(o => o.OrderId).ToPagedList(id, pageSize));
         return View(model);
     }
 }
Ejemplo n.º 28
0
 public ActionResult Search(int id = 1, string kword = null)
 {
     using (var db = new DataContext())
     {
         var query = db.Articles.AsQueryable();
         if (!string.IsNullOrWhiteSpace(kword))
             query = query.Where(a => a.Title.Contains(kword));
         var model = query.OrderByDescending(a => a.PubDate).ToPagedList(id, 5);
         return View(model);
     }
 }
Ejemplo n.º 29
0
        public ActionResult StoredProcedure(int id = 1)
        {
            using (var db = new DataContext())
            {
                var pageSize = 5;
                var startIndex = (id - 1)*pageSize + 1;
                SqlParameter prmStart = new SqlParameter("@startIndex", startIndex);
                SqlParameter prmEnd = new SqlParameter("@endIndex", startIndex + pageSize);
                SqlParameter prmTotal = new SqlParameter("@totalItems", SqlDbType.Int);
                prmTotal.Direction = ParameterDirection.Output;

                var articles =
                    db.Database.SqlQuery<Article>(
                        "exec [USP_GetPagedArticleList] @startIndex,@endIndex,@totalItems out", prmStart, prmEnd,
                        prmTotal).ToList();
                var totalItems = (int) prmTotal.Value;
                var model = new PagedList<Article>(articles, id, pageSize, totalItems);
                return View(model);
            }
        }
Ejemplo n.º 30
0
 private ActionResult ajaxSearchPostResult(string emp, int id = 1)
 {
     using (var db = new DataContext())
     {
         var qry = db.Orders.AsQueryable();
         if (!string.IsNullOrWhiteSpace(emp))
             qry = qry.Where(a => a.EmployeeName.Contains(emp));
         var model = qry.OrderBy(o=>o.OrderId).ToPagedList(id, 5);
         if (Request.IsAjaxRequest())
             return PartialView("_AjaxSearchPost", model);
         return View(model);
     }
 }