Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System.Web.Mvc;
  2. using AjaxPaging.Models;
  3.  
  4. namespace AjaxPaging.Controllers
  5. {
  6.     [HandleError]
  7.     public class HomeController : Controller
  8.     {
  9.         private readonly PersonRepository _personRepository = new PersonRepository();
  10.         public ActionResult Index(string criteria, int page = 1 )
  11.         {
  12.             ViewData["Message"] = "Welcome to ASP.NET MVC!";
  13.  
  14.             int total;
  15.             var persons = string.IsNullOrEmpty(criteria)
  16.                                 ? _personRepository.Get(page, out total)
  17.                                 : _personRepository.Get(page, criteria, out total);
  18.  
  19.             ViewData["page"] = page;
  20.             ViewData["total"] = total;
  21.             ViewData["criteria"] = criteria;
  22.  
  23.             return View(persons);
  24.         }
  25.  
  26.         public ActionResult GetPersons(string criteria, int page)
  27.         {
  28.             int total;
  29.  
  30.             var persons = string.IsNullOrEmpty(criteria)
  31.                                 ? _personRepository.Get(page, out total)
  32.                                 : _personRepository.Get(page, criteria, out total);
  33.  
  34.             ViewData["page"] = page;
  35.             ViewData["total"] = total;
  36.             ViewData["criteria"] = criteria;
  37.  
  38.             return View("_PersonList", persons);
  39.         }
  40.     }
  41. }
  42.