public ActionResult Index(int page = 1) { IEnumerable <User> Users; int PageSize = 10; int TotalCount = Logic.CountUsers(); Users = Logic.GetAll(null, o => o.OrderBy(i => i.Id), "Roles", PageSize, (PageSize * (page - 1))); int pageCount = (TotalCount % PageSize == 0 ? TotalCount / PageSize : (TotalCount / PageSize + 1)); var result = new PagedListModel <User>(Users, TotalCount, pageCount, page); return(View(result)); }