Exemplo n.º 1
0
        public override void Delete(BaseEntity entity)
        {
            User u = entity as User;

            if (u.Id > 0)// check if user is not table!
            {
                PlayerDb   playerDb = new PlayerDb();
                PlayerList temp     = playerDb.GetPlayersByUserId(u.Id);// get a lidst with all players of this user

                foreach (Player p in temp)
                {
                    playerDb.Delete(p);
                }

                FriendDb       friendDb = new FriendDb();
                ConnectionList friends  = friendDb.SelectByUserId(u.Id);

                foreach (Friendship f in friends)
                {
                    friendDb.Delete(f);
                }


                if (u != null)
                {
                    Updated.Add(new ChangeEntity(CreateDeleteSql, entity));
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        protected override BaseEntity CreateModel(BaseEntity entity)
        {
            PlayerDb playerDb = new PlayerDb();
            GameDb   gameDb   = new GameDb();

            PlayerGameConnection con = entity as PlayerGameConnection;

            con.Id     = (int)Reader["ID"];
            con.Player = playerDb.GetPlayerById((int)Reader["player_id"]);
            con.Game   = gameDb.GetGameById((int)Reader["game_id"]);
            return(con);
        }
Exemplo n.º 4
0
        protected override BaseEntity CreateModel(BaseEntity entity)
        {
            PlayerDb db   = new PlayerDb();
            Game     game = entity as Game;

            game.Id = (int)Reader["ID"];


            game.Players.Add((Player)db.GetPlayerById((int)Reader["player_1_id"]));
            game.Players.Add((Player)db.GetPlayerById((int)Reader["player_2_id"]));
            game.Players.Add((Player)db.GetPlayerById((int)Reader["player_3_id"]));
            game.Players.Add((Player)db.GetPlayerById((int)Reader["player_4_id"]));
            game.Players.Add((Player)db.GetPlayerById((int)Reader["table_id"]));


            game.StartTime = (DateTime)Reader["start_date"];
            game.EndTime   = (DateTime)Reader["end_date"];
            game.Loser     = (int)Reader["losser_id"];

            return(game);
        }