// GET: CMSUsuario public ActionResult Index(string sSortOrder, string sCurrentFilter, string sSearchString, int?pagina) { ViewBag.CurrentSort = sSortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sSortOrder) ? "nombre_desc" : ""; ViewBag.CorreoSortParm = sSortOrder == "correo" ? "correo_desc" : "correo"; if (sSearchString != null) { pagina = 1; } else { sSearchString = sCurrentFilter; } ViewBag.CurrentFilter = sSearchString; var rowsUsuario = Funcion.GetAllUsers(); if (!String.IsNullOrEmpty(sSearchString)) { rowsUsuario = rowsUsuario.Where(s => s.Nombre.ToUpper().Contains(sSearchString.ToUpper())); } switch (sSortOrder) { case "nombre_desc": rowsUsuario = rowsUsuario.OrderByDescending(s => s.Nombre); break; case "correo": rowsUsuario = rowsUsuario.OrderBy(s => s.Correo).ThenBy(s => s.Nombre); break; case "correo_desc": rowsUsuario = rowsUsuario.OrderByDescending(s => s.Correo).ThenBy(s => s.Nombre); break; default: rowsUsuario = rowsUsuario.OrderBy(s => s.Nombre); break; } int pageNumber = (pagina ?? 1); ViewBag.Pagina = pageNumber; return(View(rowsUsuario.ToPagedList(pageNumber, pageSize))); }