public ActionResult Index(int id = 1) { var page = id; var allItemsCount = this.articles .GetAll() .Count(x => x.Type == ArticleType.Design && x.AuthorId == this.UserProfile.Id); var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage); var arts = this.articles .GetByUserId(this.UserProfile.Id) .Where(x => x.Type == ArticleType.Design) .OrderByDescending(x => x.CreatedOn) .Skip((page - 1) * ItemsPerPage) .Take(ItemsPerPage) .To <ArticleViewModel>() .ToList(); var paginationModel = new PaginationViewModel() { CurrentPage = page, TotalPages = totalPages, Path = "/Users/Design/Index/" }; var model = new ArtIndexViewModel() { PaginationModel = paginationModel, ArtArticles = arts }; return(this.View(model)); }
// GET: Public/Art public ActionResult Index(int page = 1) { // var page = page; var allItemsCount = this.articles.GetAll().Count(x => x.Type == ArticleType.Art); var totalPages = (int)Math.Ceiling(allItemsCount / (decimal)ItemsPerPage); var arts = this.articles .GetAll() .Where(x => x.Type == ArticleType.Art) .OrderByDescending(x => x.CreatedOn) .Skip((page - 1) * ItemsPerPage) .Take(ItemsPerPage) .To <ArticleViewModel>() .ToList(); var paginationModel = new PaginationViewModel() { CurrentPage = page, TotalPages = totalPages, Path = "/Art?page=" }; var model = new ArtIndexViewModel() { PaginationModel = paginationModel, ArtArticles = arts }; return(this.View(model)); }