public ActionResult UserIndex(string category, int?id, int page = 1) { List <Product> ProductList = db.Products.ToList(); var nrObj = ProductList.Skip((page - 1) * PageSize).Take(PageSize).ToList(); ViewBag.totalPages = Math.Ceiling((double)ProductList.Count() / PageSize); for (int i = 1; i < ViewBag.totalPages; i++) { ViewBag.product = nrObj; } //List<Category> CategoryList = db.Categories.ToList(); //ViewBag.ctg = CategoryList; var ctgList = iCategoryRepository.FindAll(); var model = new CategoryViewModel() { Categories = new List <Category>() }; ViewBag.ctg = ctgList; var agectgList = iCategoryRepository.AFindAll(); var amodel = new CategoryViewModel() { ACategories = new List <GenderAgeCategory>() }; ViewBag.agectg = agectgList; return(View()); }