private static void TallyBallotVotes(VotingViewModel viewModel, List <VoteResult> electionResults, Ballot ballot) { Log.Info("Tallying Votes"); electionResults.AddRange(viewModel.PresidentAndVicePres.Select(presidentAndVice => new VoteResult { VoteResultsId = Guid.NewGuid(), BallotId = ballot.BallotId, RankingVoteId = presidentAndVice.RankingVoteItemId, Ranking = presidentAndVice.Ranking, })); electionResults.AddRange(viewModel.StateRep.Select(stateRep => new VoteResult { VoteResultsId = Guid.NewGuid(), BallotId = ballot.BallotId, MultipleVoteId = stateRep.MultipleVoteItemId, VotedFor = stateRep.VotedFor, })); electionResults.Add(new VoteResult { VoteResultsId = Guid.NewGuid(), BallotId = ballot.BallotId, SingleVoteId = viewModel.SupremeCourt.SingleVoteTicketId, VoteYes = viewModel.SupremeCourt.YesVote, VoteNo = viewModel.SupremeCourt.NoVote, }); electionResults.Add(new VoteResult { VoteResultsId = Guid.NewGuid(), BallotId = ballot.BallotId, SingleVoteId = viewModel.BallotIssue.SingleVoteTicketId, VoteYes = viewModel.BallotIssue.YesVote, VoteNo = viewModel.BallotIssue.NoVote, }); }
private List <VoteResult> CheckForElectionWriteIns(VotingViewModel viewModel, List <VoteResult> electionResults, Ballot ballot) { if (viewModel.PresidentWriteIn.PrimeCandidateItem.Name != null) { electionResults = Manager.RankedVotingManager.AddRankingWriteInToElection(electionResults, viewModel.PresidentWriteIn, ballot.BallotId, viewModel.PresidentAndVicePres.First()); } if (viewModel.StateRepWriteIn.CandidateItem.Name != null) { electionResults = Manager.MultiVoteManager.AddMultiVoteWriteInToElection(electionResults, viewModel.StateRepWriteIn, ballot.BallotId, viewModel.StateRep.First()); } return(electionResults); }