Пример #1
0
        public async Task <IActionResult> AddVoteToElection(AddVoteToElectionRequest request)
        {
            var Voter = PersonName.Create(request.firstName, request.lastName);

            Election election = await _electionService.AddVoteToElection(request.ElectionId, request.CandidateId, Voter);

            var currentCandidacy = election.Candidacies.First(x => x.Candidate.Id == request.CandidateId);
            var response         = new VoteAddedToElectionResponse
            {
                ElectionId  = request.ElectionId,
                CandidateId = request.CandidateId,
                VoterName   = Voter,
                TotalVotes  = currentCandidacy.Ballots.Count()
            };

            return(Ok(response));
        }