public ActionResult GetClients() { // Get the list of clients from the database var clients = from c in _processor.GetClients(User.Identity.Name) select new ClientModel(c); return(View(new GridModel <ClientModel>(clients))); }
/// <summary> /// Gets the clients from the database. /// </summary> public ActionResult GetClients(JqGridParametersModel parameters) { // Get the list of clients from the database var clients = _processor.GetClients(User.Identity.Name) .OrderBy(c => c.ClientName) .Select(c => new ClientModel(c)) .Skip(parameters.Rows * (parameters.Page - 1)) .Take(parameters.Rows).ToList(); var recordCount = clients.Count; return(Json( new JqJsonModel <ClientModel>(clients) { CurrentPage = parameters.Page == 0 ? 1 : parameters.Page, RecordCount = recordCount, TotalPages = recordCount % parameters.Rows == 0 ? recordCount / parameters.Rows : (recordCount / parameters.Rows) + 1 }, JsonRequestBehavior.AllowGet )); }