Exemplo n.º 1
0
        //search and paging
        public ActionResult Search(string keyword, int page = 1, int pageSize = 2)
        {
            var productView = new ProductViewHome();
            int totalRecord = 0;

            //get list pet toy sale off
            ViewBag.viewPetToySaleOff = productView.getViewPeTToySaleOff();
            //get list search
            var allPettoy = new PetToyModel().Search(keyword, ref totalRecord, page, pageSize);

            ViewBag.keyword = keyword;
            ViewBag.Total   = totalRecord;
            ViewBag.Page    = page;

            int maxPage   = 5;//maximum page display on website
            int totalPage = 0;

            totalPage = (int)Math.Ceiling((double)totalRecord / pageSize);

            ViewBag.totalPage = totalPage;
            ViewBag.maxPage   = maxPage;
            // first page
            ViewBag.first = 1;
            //last page
            ViewBag.last = totalPage;
            //next page
            ViewBag.next = page + 1;
            //prev page
            ViewBag.prev = page - 1;

            return(View(allPettoy));
        }
Exemplo n.º 2
0
        // GET: PetToy
        public ActionResult Index(int page = 1, int pageSize = 4)
        {
            var productView = new ProductViewHome();
            int totalRecord = 0;

            // get list sale off pet toy
            ViewBag.viewPetToySaleOff = productView.getViewPeTToySaleOff();
            var allPettoy = new PetToyModel().getAllPetToys(ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 5;//maximum page link display on website
            int totalPage = 0;

            //caculator total page
            totalPage = (int)Math.Ceiling((double)totalRecord / pageSize);

            ViewBag.totalPage = totalPage;
            ViewBag.maxPage   = maxPage;
            // first page
            ViewBag.first = 1;
            //last page
            ViewBag.last = totalPage;
            //next page
            ViewBag.next = page + 1;
            //prev page
            ViewBag.prev = page - 1;

            return(View(allPettoy));
        }