public void Candidate(Party party, PartyMember member) { var voting = party.PartyPresidentVotings.Last(); PartyPresidentCandidate candidate = new PartyPresidentCandidate() { Citizen = member.Citizen, PartyPresidentVoting = voting }; partyRepository.AddPresidentCandidate(candidate); partyRepository.SaveChanges(); }
public void VoteForPresident(PartyMember member, PartyPresidentCandidate candidate) { var party = member.Party; PartyPresidentVote vote = new PartyPresidentVote() { CitizenID = member.CitizenID, PartyPresidentCandidateID = candidate.ID, PartyPresidentVoting = party.GetLastPresidentVoting() }; partyRepository.AddPartyPresidentVote(vote); partyRepository.SaveChanges(); }
public string CanVoteOnCandidate(PartyPresidentCandidate candidate, Citizen voter) { var voting = candidate.PartyPresidentVoting; if (voting.VotingStatusID != (int)VotingStatusEnum.NotStarted) { return("Wrong candidate!"); } var party = candidate.PartyPresidentVoting.Party; if (voter.PartyMember == null || voter.PartyMember.PartyID != party.ID) { return("You are not a member of this party!"); } if (voting.PartyPresidentVotes.Any(v => v.CitizenID == voter.ID)) { return("You cannot vote again!"); } return(null); }
public void AddPresidentCandidate(PartyPresidentCandidate candidate) { context.PartyPresidentCandidates.Add(candidate); }
public PartyCandidateViewModel(PartyPresidentCandidate candidate) : base(candidate.Citizen.Entity) { VoteCount = candidate.PartyPresidentVotes.Count(); CandidateID = candidate.ID; }