public ActionResult Index(string sortExpression = "CreatedDate DESC", int page = 1, int pageSize = 20) { int pageIndex = page - 1; int count = _quoteRepo.CountAll(); if (pageSize == 0 && count != 0) { pageSize = count; } if (count == 0) { pageSize = 20; } var quotes = _quoteRepo.LoadAll(sortExpression, pageSize, pageIndex) .Select(quote => new QuoteModel() { Id = quote.Id, CreatedById = quote.CreatedBy != null ? quote.CreatedBy.Id : 0, CreatedByName = quote.CreatedBy != null ? quote.CreatedBy.UserName : string.Empty, Author = quote.Author, Website = quote.Website, Content = quote.Content, CreatedDate = quote.CreatedDate }).ToList(); var model = quotes; //new StaticPagedList<QuoteModel>(quotes, page, pageSize, count); return(View("~/Plugins/RandomQuotesPlugin/Views/Index.cshtml", model)); }