public ActionResult Index(string option, string search, int page = 1, int pageSize = 8) { if (option == "Nombre") { ViewBag.idTipo = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listapersona = personaBll.Find(x => x.nombreCompleto == search && x.idTipo == 2 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listapersona, page, pageSize); return(View(model)); } else if (option == "Cédula") { ViewBag.idTipo = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listapersona = personaBll.Find(x => x.cedula == search && x.idTipo == 2 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listapersona, page, pageSize); return(View(model)); } else if (option == "Representante legal") { ViewBag.idTipo = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listapersona = personaBll.Find(x => x.RepresentanteLegal == search && x.idTipo == 2 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listapersona, page, pageSize); return(View(model)); } else if (option == "Representante social") { ViewBag.idTipo = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listapersona = personaBll.Find(x => x.RepresentanteSocial == search && x.idTipo == 2 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listapersona, page, pageSize); return(View(model)); } else { ViewBag.idTipo = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listapersona = personaBll.Find(x => x.cedula == search && x.idTipo == 2 || x.nombreCompleto == search && x.idTipo == 2 || x.idPersona.ToString() == search && x.idTipo == 2 || x.idTipo.ToString() == search && x.idTipo == 2 || search == null && x.idTipo == 2).ToList(); PagedList <Persona> model = new PagedList <Persona>(listapersona, page, pageSize); return(View(model)); } }
public ActionResult Index(string option, string search, string currentFilter, string sortOrder, int?page) { try { tablaGeneralBLL = new TablaGeneralBLLImpl(); personaBll = new PersonasBLLImpl(); } catch (Exception ex) { ex = new Exception(); return(View()); } ViewBag.CurrentSort = sortOrder; if (search != null) { page = 1; } else { search = currentFilter; } ViewBag.CurrenFilter = search; int pageSize = 4; int pageNumber = (page ?? 1); if (option == "Cédula") { ViewBag.idPersona = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listaPersonas = personaBll.Find(x => x.cedula == search && x.idTipo == 1 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listaPersonas, pageNumber, pageSize); return(View(model.ToPagedList(pageNumber, pageSize))); } else if (option == "Nombre Completo") { ViewBag.idPersona = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listaPersonas = personaBll.Find(x => x.cedula == search && x.idTipo == 1 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listaPersonas, pageNumber, pageSize); return(View(model)); } else if (option == "Correo") { ViewBag.idPersona = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listaPersonas = personaBll.Find(x => x.cedula == search && x.idTipo == 1 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listaPersonas, pageNumber, pageSize); return(View(model)); } else if (option == "Observación") { ViewBag.idPersona = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); List <Persona> listaPersonas = personaBll.Find(x => x.cedula == search && x.idTipo == 1 || search == null).ToList(); PagedList <Persona> model = new PagedList <Persona>(listaPersonas, pageNumber, pageSize); return(View(model)); } else { ViewBag.idPersona = new SelectList(tablaGeneralBLL.Consulta("Persona", "tipo"), "idTablaGeneral", "descripcion"); ViewBag.Cedula = String.IsNullOrEmpty(sortOrder) ? "cedulades" : ""; ViewBag.NombreCompleto = sortOrder == "NombreCompleto" ? "nombrecomdes" : "NombreCompleto"; var personas = from s in personaBll.Find(x => search == null && x.idTipo == 1) select s; switch (sortOrder) { case "cedulades": personas = personas.OrderByDescending(s => s.cedula); break; case "nombrecomdes": personas = personas.OrderByDescending(s => s.nombreCompleto); break; case "NombreCompleto": personas = personas.OrderBy(s => s.nombreCompleto); break; default: personas = personas.OrderBy(s => s.cedula); break; } List <Persona> listaPersonas = personas.ToList(); foreach (Persona persona in listaPersonas) { tablaGeneralBLL = new TablaGeneralBLLImpl(); persona.TablaGeneral = tablaGeneralBLL.Get(persona.idTipo); //TablaGeneral es el {get;set} para poder traer idTipo de tabla general } PagedList <Persona> model = new PagedList <Persona>(listaPersonas, pageNumber, pageSize); return(View(model)); } }
public JsonResult Search(string name) { var resultado = personaBll.Find(x => x.cedula.Contains(name)).Select(x => x.cedula).Take(11).ToList(); return(Json(resultado, JsonRequestBehavior.AllowGet)); }