public void NotifyContestants(Winner winner) { foreach (KeyValuePair <int, Contestant> pair in contestants) { if (pair.Value.IsWinner == true) { winner.Notify(); } else { } } }
public string PickWinner() { int index; Winner winner = new Winner(); int winnerKey; Contestant winnerContestant; Random random = new Random(); index = random.Next(0, contestants.Count - 1); winnerContestant = contestants.ElementAt(index).Value; winnerKey = contestants.ElementAt(index).Key; TransferContestantToWinner(winner, winnerContestant, winnerKey); winner.Notify(); NotifyContestants(); SendEmail(WinnersMessage(winner)); return(winner.FirstName + " " + winner.LastName); }