Exemple #1
0
        // GET: Home
        public ActionResult Index(int page = 0, int part = 16, string sort = "Id", string typesort = "asc")
        {
            var total = db.BaiHats.Count() / part;

            var paginate = Paginate.create(page, part, total);
            var _qr      = db.BaiHats.Where(
                delegate(BaiHat bh) {
                if (Request["search"] == null)
                {
                    return(true);
                }
                if (bh.CaSi.TenCS.ToUpper().Contains(Request["search"].ToUpper()))
                {
                    return(true);
                }
                if (bh.TacGia.TenTG.ToUpper().Contains(Request["search"].ToUpper()))
                {
                    return(true);
                }
                if (bh.TenBH.ToUpper().Contains(Request["search"].ToUpper()))
                {
                    return(true);
                }
                if (bh.NoiDung.ToUpper().Contains(Request["search"].ToUpper()))
                {
                    return(true);
                }
                return(false);
            });

            var qr = _qr.OrderBy(p => p.MaBH);

            if (sort == "Ten")
            {
                qr = _qr.OrderBy(p => p.TenBH);
            }
            if (sort == "Ten")
            {
                qr = _qr.OrderBy(p => p.TenBH);
            }
            if (sort == "namXB")
            {
                qr = _qr.OrderBy(p => p.NamSX);
            }
            if (sort == "hangSX")
            {
                qr = _qr.OrderBy(p => p.HangSX);
            }


            var meta = _qr.Skip(paginate["page"] * part).Take((paginate["page"] + 1) * part);

            ViewBag.paginate = paginate;

            var data = meta.ToList();

            return(View(data));
        }
        // GET: ProductAdmin
        public ActionResult Index(int page = 0, int part = 30)
        {
            var total    = db.Product.Count() / part;
            var paginate = Paginate.create(page, part, total);
            var data     = db.Product.OrderBy(p => p.Id).Skip(paginate["page"] * part).Take((paginate["page"] + 1) * part).ToList();

            ViewBag.paginate = paginate;
            return(View(data));
        }