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); }
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); }
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 } }
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); }
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(); }
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(); } }
public void UpdatePlayerInvitation(LiteDatabase db, TeamInvitation inv) { var collections = db.GetCollection <TeamInvitation>("team_invitations"); collections.Update(inv); }
public void rejectInvitation(TeamInvitation inv) { Invitations.Remove(inv); //Simply remove invitation }