Example #1
0
 /// <summary>
 /// Adds the given vote to the post and returns how much reputation that vote is worth, does not add the reputation to the author.
 /// </summary>
 /// <param name="vote"></param>
 /// <returns></returns>
 public override int AddVote(Vote vote)
 {
     if (vote is DownVote)
     {
         this.DownVotes.Add((DownVote)vote);
         return Settings.Reputation.Answers.DownVote;
     }
     else if (vote is UpVote)
     {
         this.UpVotes.Add((UpVote)vote);
         return Settings.Reputation.Answers.UpVote;
     }
     return 0;
 }
Example #2
0
 protected ViewVoteModel(Vote vote)
 {
     this.Voter = vote.Voter.ToModel();
     this.DateVoted = vote.DateVoted.Value;
     this.Id = vote.Id;
 }
Example #3
0
 /// <summary>
 /// Gets the amount of reputation that the given vote is worth.
 /// </summary>
 /// <param name="v">The vote the get the reputation value of.</param>
 /// <returns></returns>
 public override int GetVoteValue(Vote v)
 {
     if (v is DownVote)
     {
         return Settings.Reputation.Answers.DownVote;
     }
     else if (v is UpVote)
     {
         return Settings.Reputation.Answers.UpVote;
     }
     return 0;
 }
Example #4
0
 /// <summary>
 /// Removes the given vote from the post and returns how much reputation the removal is worth, does not add/remove that reputation from the author.
 /// </summary>
 /// <param name="vote">The vote to remove from the post.</param>
 /// <returns></returns>
 public override int RemoveVote(Vote vote)
 {
     if (vote is DownVote)
     {
         if (this.DownVotes.Remove((DownVote)vote))
         {
             return -Settings.Reputation.Answers.DownVote;
         }
     }
     else if (vote is UpVote)
     {
         if (this.UpVotes.Remove((UpVote)vote))
         {
             return -Settings.Reputation.Answers.UpVote;
         }
     }
     return 0;
 }
Example #5
0
 public override System.Linq.Expressions.Expression<Func<int>> GetVoteValueExpression(Vote v)
 {
     if (v is DownVote)
     {
         return () => Settings.Reputation.Answers.DownVote;
     }
     else if (v is UpVote)
     {
         return () => Settings.Reputation.Answers.UpVote;
     }
     return () => 0;
 }
Example #6
0
 /// <summary>
 /// Removes the given vote from the post and returns how much reputation the removal is worth, does not add/remove that reputation from the author.
 /// </summary>
 /// <param name="vote">The vote to remove from the post.</param>
 /// <returns></returns>
 public abstract int RemoveVote(Vote vote);
Example #7
0
 public abstract Expression<Func<int>> GetVoteValueExpression(Vote v);
Example #8
0
 /// <summary>
 /// Gets the amount of reputation that the given vote is worth.
 /// </summary>
 /// <param name="v">The vote the get the reputation value of.</param>
 /// <returns></returns>
 public abstract int GetVoteValue(Vote v);
Example #9
0
 /// <summary>
 /// Adds the given vote to the post and returns how much reputation it is worth, does not add that reputation to the author.
 /// </summary>
 /// <param name="vote">The vote to add to the post.</param>
 /// <returns></returns>
 public abstract int AddVote(Vote vote);