/// <summary>
 /// Create a new UserVote object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static UserVote CreateUserVote(global::System.Int32 id)
 {
     UserVote userVote = new UserVote();
     userVote.ID = id;
     return userVote;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the UserVotes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserVotes(UserVote userVote)
 {
     base.AddObject("UserVotes", userVote);
 }
예제 #3
0
 private void UpVote_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     var vote = pastVote();
     var annotation = selectedAnnotation();
     if (annotation == null) return;
     if (vote == null) {
         var newVote = new UserVote() {
             UserID = this.currentUser.ID,
             AnnotationID = currentAnnotationID,
             Vote = true
         };
         db.UserVotes.AddObject(newVote);
         annotation.UpVotes++;
         highlightUpArrow();
     } else {
         if (vote.Vote.Value) {
             annotation.UpVotes--;
             db.UserVotes.DeleteObject(vote);
             resetArrows();
         } else {
             vote.Vote = true;
             annotation.DownVotes--;
             annotation.UpVotes++;
             highlightUpArrow();
         }
     }
     db.SaveChanges();
 }