// GET: Citizens public async Task <IActionResult> Index() { var citizens = (await _citizenServices.GetCitizenByConditionAsync(c => c.IsActive == true)) .OrderBy(c => c.Name).ThenBy(c => c.LastName); return(View(citizens.ToList())); }
public async Task <IActionResult> Index(VotationLoginViewModel votationLoginViewModel) { if (ModelState.IsValid) { if (await _citizenService.VerifyExistAsync(votationLoginViewModel.DNI) == false) { ViewBag.Message = "EL ciudadano no existe o esta inactivo."; return(View(votationLoginViewModel)); } if (await _electionService.VerifyElectionOpenAsync() == false) { ViewBag.Message = "No hay ningun proceso electoral en estos momentos."; return(View(votationLoginViewModel)); } if (await _electionService.VerifyCitizenVoteAsync(votationLoginViewModel.DNI)) { ViewBag.Message = "Usted ya ejercion su derecho al voto."; return(View(votationLoginViewModel)); } Citizen citizen = await _citizenService.GetCitizenByConditionAsync(c => c.Dni == votationLoginViewModel.DNI).Result.FirstOrDefaultAsync(); HttpContext.Session.SetInt32(Configuration.Citizen, citizen.Id); return(RedirectToAction("Votation")); } return(View(votationLoginViewModel)); }