public void AddScore(string username, long points)
 {
     if (string.IsNullOrEmpty(username) || !UserExists(username))
     {
         return;
     }
     using (var context = new TetrisDbContext())
     {
         var user      = context.Users.FirstOrDefault(u => u.Name == username);
         var highscore = new HighScore
         {
             User   = user,
             Points = points,
             Date   = DateTime.Now
         };
         context.HighScores.Add(highscore);
         context.SaveChanges();
     }
 }
        public void LoginUser(string username)
        {
            User user = new User()
            {
                Name = username
            };

            using (var context = new TetrisDbContext())
            {
                if (context.Users.Any(u => u.Name == username))
                {
                    var userFromDb = context.Users.First(u => u.Name == username);
                    AuthenticationManager.Login(userFromDb);
                }
                else
                {
                    context.Users.Add(user);
                    context.SaveChanges();
                    AuthenticationManager.Login(user);
                }
            }
        }