public ActionResult Index(string Document, string CustomerId, int?FilterId, int?Comuna, int?VotingPlaceId, int?WorkPlaceId, int?page = null) { ViewBag.uno = FilterId; ViewBag.dos = Comuna; ViewBag.tres = VotingPlaceId; ViewBag.cuatro = WorkPlaceId; page = (page ?? 1); var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); if (user == null) { return(RedirectToAction("Index", "Home")); } if (!string.IsNullOrEmpty(Document)) { if (Utilidades.isNumeric(Document)) { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name"); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); double doc = Convert.ToDouble(Document); var link = db.Links.Where(v => v.Document == doc); return(View(link.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 5))); } } if (!string.IsNullOrEmpty(CustomerId)) { if (Utilidades.isNumeric(CustomerId)) { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name"); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); int doc = Convert.ToInt32(CustomerId); var link = db.Links.Where(b => b.LinkId == doc); return(View(link.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 5))); } } if (FilterId > 0) { if (FilterId == 1)//GENERAL { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name", FilterId); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); var linkGeneral = db.Links.Where(b => b.CompanyId == user.CompanyId); return(View(linkGeneral.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 5))); } if (FilterId == 2)//COMUNA { if (Comuna > 0) { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name", FilterId); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name", Comuna); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); var linkComuna = db.Links.Where(b => b.CompanyId == user.CompanyId && b.CommuneId == Comuna); return(View(linkComuna.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 10))); } } if (FilterId == 3)//LUGAR DE VOTACION { if (VotingPlaceId > 0) { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name", FilterId); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name", VotingPlaceId); var linkVotacion = db.Links.Where(b => b.CompanyId == user.CompanyId && b.VotingPlaceId == VotingPlaceId); return(View(linkVotacion.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 10))); } } if (FilterId == 4) { if (WorkPlaceId > 0) { ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name", FilterId); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name", WorkPlaceId); var linkWork = db.Links.Where(b => b.CompanyId == user.CompanyId && b.WorkPlaceId == WorkPlaceId); return(View(linkWork.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 10))); } } } ViewBag.FilterId = new SelectList( CombosHelper.GetFilters(), "FiltersId", "name"); ViewBag.VotingPlaceId = new SelectList( CombosHelper.GetVotingPlaces(), "VotingPlaceId", "Name"); ViewBag.WorkPlaceId = new SelectList( CombosHelper.GetWorkPlaces(), "WorkPlaceId", "Name"); ViewBag.Comuna = new SelectList( CombosHelper.GetCommunes(), "CommuneId", "Name"); var links = db.Links.Where(b => b.CompanyId == user.CompanyId); return(View(links.OrderBy(b => b.CompanyId).ThenBy(b => b.FirstName).ToPagedList((int)page, 10))); }