Exemple #1
0
 /// <summary>
 /// adds a player to the database
 /// </summary>
 /// <param name="nameString"></param>
 /// <returns></returns>
 public bool AddPlayer(string nameString)
 {
     try
     {
         entities.Player.Add(new Player()
         {
             name = nameString
         });
         entities.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemple #2
0
        private void EndProcess()
        {
            time.Stop();
            Game game = new Game()
            {
                player_id  = player.id,
                difficulty = diff,
                mistakes   = this.mistakes,
                won        = this.won,
                date       = DateTime.Now,
                duration   = (int)Math.Round(time.Elapsed.TotalSeconds + 0.5)
            };

            entities.Game.Add(game);
            entities.SaveChanges();
            endGame.Invoke(won, game);
        }