コード例 #1
0
        public async Task <IActionResult> Votation(ElectionVotationViewModel electionVotationViewModel)
        {
            if (!HttpContext.Session.GetInt32(Configuration.Citizen).HasValue)
            {
                return(RedirectToAction(nameof(Index)));
            }
            Election election = await _electionService.GetElectionByConditionAsync(e => e.IsActive == true).Result.Include(e => e.ElectionPosition).ThenInclude(ep => ep.Position).FirstOrDefaultAsync();

            if (electionVotationViewModel.Id == 0)
            {
                electionVotationViewModel.Id   = election.Id;
                electionVotationViewModel.Name = election.Name;
            }
            electionVotationViewModel.Postions = election.ElectionPosition.Select(ep => ep.Position).ToList();
            return(View(electionVotationViewModel));
        }