public ActionResult Search(string keywordPet, int page = 1, int pageSize = 2)
        {
            var productView = new ProductViewHome();
            //initialize
            int totalRecord = 0;

            //Save Pet to pass data to another view
            ViewBag.viewPetSaleOff = productView.getViewPetSaleOff();
            //Get all pet
            var allPet = new PetModel().Search(keywordPet, ref totalRecord, page, pageSize);

            //Save total page, keyword and page to pass data to another view
            ViewBag.Total   = totalRecord;
            ViewBag.keyword = keywordPet;
            ViewBag.Page    = page;

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

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

            //Save data page to pass data to another view
            ViewBag.totalPage = totalPage;
            ViewBag.maxPage   = maxPage;
            ViewBag.first     = 1;
            ViewBag.last      = totalPage;
            ViewBag.next      = page + 1;
            ViewBag.prev      = page - 1;
            return(View(allPet));
        }
Beispiel #2
0
        // GET: Home
        public ActionResult Index()
        {
            var productView = new ProductViewHome();

            ViewBag.viewPet        = productView.getViewPet(4);
            ViewBag.viewPetFood    = productView.getViewPetFood(4);
            ViewBag.viewPetToy     = productView.getViewPetToys(4);
            ViewBag.viewPetSaleOff = productView.getViewPetSaleOff();
            return(View());
        }