Example #1
0
        public void Vote(Participant participant)
        {
            bool newParticipant  = true;
            bool saveParticipant = true;

            List <Participant> participants = participantsRepository.List();

            foreach (var p in participants)
            {
                if (p.Name == participant.Name)
                {
                    if (p.Attend != participant.Attend)
                    {
                        p.Attend      = participant.Attend;
                        p.Reason      = participant.Reason;
                        p.ArrivalDate = participant.ArrivalDate;
                    }
                    else
                    {
                        saveParticipant = false;
                    }
                    newParticipant = false;
                    continue;
                }
            }
            if (newParticipant)
            {
                participants.Add(participant);
            }

            if (saveParticipant)
            {
                participantsRepository.Save(participants);
            }
        }
Example #2
0
        public void Vote(string name, bool attend)
        {
            bool newParticipant  = true;
            bool saveParticipant = true;

            List <Participant> participants = participantsRepository.List();

            foreach (var p in participants)
            {
                if (p.Name == name)
                {
                    if (p.Attend != attend)
                    {
                        p.Attend = attend;
                    }
                    else
                    {
                        saveParticipant = false;
                    }
                    newParticipant = false;
                    continue;
                }
            }
            if (newParticipant)
            {
                participants.Add(new Participant(name, attend));
            }

            if (saveParticipant)
            {
                participantsRepository.Save(participants);
            }
        }