Пример #1
0
        public void CreatePlayer(string nick, string pass)
        {
            PLAYERS pl = new PLAYERS();

            pl.NickName   = nick;
            pl.Password   = pass;
            pl.Coins      = DEFAULT_PLAYER_COINS;
            pl.GamesCount = 0;
            pl.WinCount   = 0;

            _bJContext.PLAYERS.Add(pl);
            _bJContext.SaveChanges();
        }
Пример #2
0
        public void UpdatePlayer(int playerID, int WinnerID)
        {
            PLAYERS pl = GetPLAYERS(playerID);

            pl.GamesCount++;

            if (playerID == WinnerID)
            {
                pl.WinCount++;
            }

            _bJContext.PLAYERS.Attach(pl);
            _bJContext.Entry(pl).State = System.Data.Entity.EntityState.Modified;
            _bJContext.SaveChanges();
        }
Пример #3
0
        private PLAYERS GetPLAYERS(int playerID)
        {
            PLAYERS pl = new PLAYERS();

            using (var db = new BJContext())
            {
                var query = from s in db.PLAYERS
                            where s.PlayerID == playerID
                            select s;

                foreach (var student in query)
                {
                    if (student.PlayerID != 0)
                    {
                        pl = student;
                    }
                }
            }
            return(pl);
        }