コード例 #1
0
        public TeamInvitation getPlayerInvitation(MySqlConnection conn, Tournament t, ulong inv_id)
        {
            //Fetch invitation for player
            string          q   = string.Format("SELECT * from team_invitations WHERE ID='{0}'", inv_id);
            MySqlDataReader rdr = ExecuteQuery(conn, q);

            TeamInvitation inv = new TeamInvitation();

            while (rdr.Read())
            {
                long _uid      = rdr.GetInt64(rdr.GetOrdinal("ID"));
                long _playerid = rdr.GetInt64(rdr.GetOrdinal("player_id"));
                bool _pending  = rdr.GetBoolean(rdr.GetOrdinal("pending"));
                bool _accepted = rdr.GetBoolean(rdr.GetOrdinal("accepted"));
                long _teamid   = rdr.GetInt64(rdr.GetOrdinal("team_id"));

                inv.UID      = _uid;
                inv.team     = t.getTeamByUID(_teamid);
                inv.player   = t.getPlayerByUID(_playerid);
                inv.pending  = _pending;
                inv.accepted = _accepted;
            }

            rdr.Close();

            return(inv);
        }
コード例 #2
0
        public long registerPlayerInvitation(LiteDatabase db, TeamInvitation inv)
        {
            var  collections = db.GetCollection <TeamInvitation>("team_invitations");
            long id          = collections.Insert(inv);

            collections.EnsureIndex(x => x.UID);
            return(id);
        }
コード例 #3
0
 public void acceptInvitation(TeamInvitation inv)
 {
     if (inv.team is Team2s)
     {
         (inv.team as Team2s).addPlayer(this);
         Invitations.Remove(inv); //Simply remove invitation
     }
     else if (inv.team is Team3s)
     {
         (inv.team as Team3s).addPlayer(this);
         Invitations.Remove(inv); //Simply remove invitation
     }
 }
コード例 #4
0
        public TeamInvitation GetPlayerInvitation(LiteDatabase db, ref Tournament t, long inv_id)
        {
            var collections = db.GetCollection <TeamInvitation>("team_invitations");

            TeamInvitation inv = collections.FindOne(x => x.UID == inv_id);

            if (inv != null)
            {
                inv.team   = t.getTeamByUID(inv.teamID);
                inv.player = t.getPlayerByMainPlayerUID(inv.playerID);
            }

            return(inv);
        }
コード例 #5
0
        public void ApplySingleInvitationUpdate(MySqlConnection conn, TeamInvitation inv)
        {
            //Update Matchup to DB
            string q   = "UPDATE team_invitations SET pending = @pending, accepted=@accepted WHERE ID = @uid";
            var    cmd = GenerateCommand(conn, q);

            cmd.Parameters.AddWithValue("@uid", inv.UID);
            cmd.Parameters.AddWithValue("@pending", inv.pending);
            cmd.Parameters.AddWithValue("@accepted", inv.accepted);

            MySqlDataReader rdr = cmd.ExecuteReader();

            rdr?.Close();
        }
コード例 #6
0
        public void getPlayerInvitations(MySqlConnection conn, ref Tournament tourney, long tourn_id)
        {
            foreach (Player p in tourney._players)
            {
                //Fetch pending invitation for player
                string          q   = string.Format("SELECT * from team_invitations WHERE tournament_id = '{0}' AND player_id='{1}' AND pending=1", tourn_id, p.UID);
                MySqlDataReader rdr = ExecuteQuery(conn, q);

                while (rdr.Read())
                {
                    ulong _uid    = rdr.GetUInt64(rdr.GetOrdinal("ID"));
                    long  _teamid = rdr.GetInt64(rdr.GetOrdinal("team_id"));

                    TeamInvitation inv = new TeamInvitation();
                    inv.team = tourney.getTeamByUID(_teamid);
                    p.Invitations.Add(inv);
                }
                rdr.Close();
            }
        }
コード例 #7
0
        public void UpdatePlayerInvitation(LiteDatabase db, TeamInvitation inv)
        {
            var collections = db.GetCollection <TeamInvitation>("team_invitations");

            collections.Update(inv);
        }
コード例 #8
0
 public void rejectInvitation(TeamInvitation inv)
 {
     Invitations.Remove(inv); //Simply remove invitation
 }