Beispiel #1
0
        public DbElectionVote GetMyVote(uint avatar_id, uint cycle_id, DbElectionVoteType type)
        {
            //this isn't as straightforward as you might think.
            //we also need to include votes from:
            // - other sims on our user
            // - other sims on other users that share login ip
            //note that this criteria is duplicated in the database in the form of a BEFORE INSERT check.

            var query = "SELECT * from fso_election_votes v INNER JOIN fso_avatars va ON v.from_avatar_id = va.avatar_id " +
                        "WHERE v.election_cycle_id = @cycle_id AND v.type = @type AND va.user_id IN " +
                        "(SELECT user_id FROM fso_users WHERE last_ip = " +
                        "(SELECT last_ip FROM fso_avatars a JOIN fso_users u on a.user_id = u.user_id WHERE avatar_id = @avatar_id)" +
                        ")";

            return(Context.Connection.Query <DbElectionVote>(query,
                                                             new { avatar_id = avatar_id, cycle_id = cycle_id, type = type.ToString() }).FirstOrDefault());
        }
Beispiel #2
0
 public List <DbElectionVote> GetCycleVotesForAvatar(uint avatar_id, uint cycle_id, DbElectionVoteType type)
 {
     return(Context.Connection.Query <DbElectionVote>("SELECT * FROM fso_election_votes WHERE election_cycle_id = @cycle_id AND type = @type "
                                                      + "AND target_avatar_id = @avatar_id",
                                                      new { avatar_id = avatar_id, cycle_id = cycle_id, type = type.ToString() }).ToList());
 }
Beispiel #3
0
 public List <DbElectionVote> GetCycleVotes(uint cycle_id, DbElectionVoteType type)
 {
     return(Context.Connection.Query <DbElectionVote>("SELECT * FROM fso_election_votes WHERE election_cycle_id = @cycle_id AND type = @type",
                                                      new { cycle_id = cycle_id, type = type.ToString() }).ToList());
 }