public ActionResult Detail(String pID, int page = 1, int pageSize = 3) { var cmt = new CommentModel(); var cmtd = new CommentDetailModel(); var pet = new PetModel(); //get data of detail pet choose var petDetail = pet.getPetByID(pID); //get list all user var listAllUser = new UserManagement().getAllViewUser(); //set list relate Pet to ViewBag ViewBag.relatedPet = pet.getPetRelated(petDetail.p_id); //set list all user and pet detail to viewBag ViewBag.listUser = listAllUser; ViewBag.petDetail = petDetail; int totalRecord = 0; //get list comment in a page var allCmtOfPet = cmt.getAllCommentByPetFoodID(ref totalRecord, pID, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = page; int maxPage = 5;//maximum page link display on website int totalPage = 0; totalPage = (int)Math.Ceiling((double)totalRecord / pageSize); ViewBag.totalPage = totalPage; ViewBag.maxPage = maxPage; ViewBag.first = 1; ViewBag.last = totalPage; ViewBag.next = page + 1; ViewBag.prev = page - 1; //set list all comment reply to viewBag ViewBag.listAllCommentDetail = cmtd.getAllCommentDetail(); return(View(allCmtOfPet)); }