public void BlRemoveCard(Message m) { PlayerCardDb db = new PlayerCardDb(); PlayerCardConnection temp = db.GetConnectionByPlayerIdAndCardId(m.Target, m.Card); db.Delete(temp); }
protected override BaseEntity CreateModel(BaseEntity entity) { PlayerDb playerDb = new PlayerDb(); CardDb cardDb = new CardDb(); PlayerCardConnection con = entity as PlayerCardConnection; con.Id = (int)Reader["ID"]; con.Player = playerDb.GetPlayerById((int)Reader["player_id"]); con.Card = cardDb.SelectById((int)Reader["card_id"]); return(con); }
public void BlAddCard(Message m) { PlayerCardDb db = new PlayerCardDb(); PlayerCardConnection c = new PlayerCardConnection() { Player = m.Target, Card = m.Card }; db.Insert(c); }
public override void CreateDeleteSql(BaseEntity entity, OleDbCommand command) { PlayerCardConnection con = entity as PlayerCardConnection; command.CommandText = "DELETE FROM Player_Card_Table WHERE [ID] = @id "; //parameters command.Parameters.Add(new OleDbParameter("@id", con.Id)); Console.WriteLine("PlayerCardConnection between player [" + con.Player.Id + "] and card [" + con.Card.Id + "] DELETED"); }
public override void CreateInsertSql(BaseEntity entity, OleDbCommand command) { PlayerCardConnection con = entity as PlayerCardConnection; command.CommandText = "INSERT INTO Player_Card_Table (player_id, card_id) VALUES (@player_id, @card_id)"; //parameters command.Parameters.Add(new OleDbParameter("@player_id", con.Player.Id)); command.Parameters.Add(new OleDbParameter("@card_id", con.Card.Id)); Console.WriteLine("PlayerCardConnection between player [" + con.Player.Id + "] and card [" + con.Card.Id + "] INSERTED"); }