Ejemplo n.º 1
0
        public string RegisterNewPlayer(string userName)
        {
            var registered = (Database.PlayerTags.FirstOrDefault(x => x.PlayerGameTag == userName) != null);

            if (registered)
                return string.Format("{0} has already been registered.", userName);

            var player = new Player();

            player = Database.Players.Add(player);
            Database.SaveChanges();

            var playerTag = new PlayerTag
            {
                PlayerGameTag = userName,
                IsCurrentTag = true,

                Player = player,
                PlayerId = player.PlayerId
            };

            Database.PlayerTags.Add(playerTag);
            Database.SaveChanges();

            return "success";
        }
Ejemplo n.º 2
0
        public Player CreateNewPlayer(int tournamentId)
        {
            var player = new Player();

            var newPlayer = Database.Players.Add(player);
            Database.SaveChanges();

            var playerHistory = new PlayerGlickoHistory
            {
                PlayerId = newPlayer.PlayerId,
                Ranking = 1500,
                Deviation = 300,
                Volatility = 0.06m,
                TournamentId = tournamentId
            };

            //TODO: This may work instead of current implemenatation
            //newPlayer.PlayerGlickoHistories.Add(new PlayerGlickoHistory
            //{
            //    PlayerPlayerId = newPlayer.PlayerId,
            //    Ranking = 1500,
            //    Deviation = 300,
            //    Volatility = 0.06m,
            //    Date = tournamentDateTime
            //});

            Database.PlayerGlickoHistories.Add(playerHistory);
            Database.SaveChanges();

            return newPlayer;
        }