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); } }
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); } }
public ActionResult Voting(GuestResponse resp) { string partiesName = Request.Cookies["PartiesName"]; if (resp.Id == default) { } string name = User.Identity.Name; paticipantsRepository.Save(name, partiesName); return(Redirect("/Participants/Participants")); }
public void Vote(User user) { User temp = _repository.Users.Find((u) => u.Name == user.Name); if (temp != null) { temp.IsAttending = user.IsAttending; _repository.Save(); } else { _repository.AddUser(user); } }
public void Vote(Participant participant) { if (participant.Name != string.Empty) { Participant temp = _participantsRepository.Participants.Find((p) => p.Name == participant.Name); if (temp != null) { temp.IsAttending = participant.IsAttending; temp.PartyId = participant.PartyId; if (participant.Avatar != null) { temp.Avatar = participant.Avatar; } _participantsRepository.Save(); } else { _participantsRepository.AddUser(participant); } } }