Exemplo n.º 1
0
        public void AddCandidate(Candidate candidate)
        {
            if (candidate is null)
            {
                throw new ArgumentNullException(nameof(candidate), "You must add an existing candidate to an election.");
            }

            var isThisCandidateADuplicate = _candidacies.FirstOrDefault(x => x.Candidate == candidate) != null;

            if (!isThisCandidateADuplicate)
            {
                var candidacy = new Candidacy(this, candidate, null);
                _candidacies.Add(candidacy);

                candidate.AddCandidacy(candidacy);
            }
        }
Exemplo n.º 2
0
 public void AddCandidacy(Candidacy candidacy)
 {
     _electionCandidacies.Add(candidacy);
 }