Пример #1
0
        public static string GetHighScore()
        {
            var    db        = new LevelScoreEntities();
            int    highScore = db.Players.Max(p => p.HighScore);
            string champ     = db.Players.FirstOrDefault(p => p.HighScore == highScore).Alias;

            return(highScore.ToString() + " - " + champ);
        }
Пример #2
0
        public static bool ChangeAlias(string userId, string newAlias)
        {
            Guid guid;

            if (!Guid.TryParse(userId, out guid))
            {
                return(false);
            }
            var db = new LevelScoreEntities();

            db.Players.FirstOrDefault(p => p.UserId == guid).Alias = newAlias;
            db.SaveChanges();
            return(true);
        }
Пример #3
0
        public static string getPlayerAlias(string userId)
        {
            Guid guid;

            if (!Guid.TryParse(userId, out guid))
            {
                throw new Exception("User Id not Valid.");
            }
            var db     = new LevelScoreEntities();
            var player = db.Players.FirstOrDefault(p => p.UserId == guid);

            if (player.Alias != null)
            {
                return(player.Alias.ToString());
            }
            else
            {
                return("");
            }
        }