Exemplo n.º 1
0
        internal void Vote(ChatUser user, Guid choiceID)
        {
            PollChoice choice = Choices.FirstOrDefault(c => c.ID == choiceID);

            if (choice == null)
            {
                throw new Exception("Choice must be present");
            }

            if (!IsOpen)
            {
                throw new Exception("Poll is closed");
            }

            foreach (PollChoice thisChoice in Choices)
            {
                if (thisChoice.Votes.Contains(user))
                {
                    thisChoice.Votes.Remove(user);
                }
            }

            choice.Votes.Add(user);
            OnPropertyChanged(nameof(TotalVotes));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Occurs when a user votes on a poll
 /// </summary>
 /// <param name="user">The user that voted</param>
 /// <param name="poll">The poll that the user voted on</param>
 /// <param name="choice">The choice that the user voted for</param>
 protected virtual void OnUserVoted(ChatUser user, PollMessage poll, PollChoice choice)
 {
     //Debug.WriteLine( "User: {0}, Voted on: '{1}', Answered: {2}", user, poll.Text, choice.Text );
 }
Exemplo n.º 3
0
 public UserVotedEventArgs(ChatUser user, PollMessage poll, PollChoice choice)
 {
     User   = user;
     Choice = choice;
     Poll   = poll;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Vote for a specified poll choice
 /// </summary>
 /// <param name="choice"></param>
 public void Vote(PollChoice choice)
 {
     _chatProxy.Vote(choice);
 }