Exemple #1
0
        public async Task AcceptChallenge([FromBody] string FigherJson)
        {
            var     _userEmail        = userEmail().Result;
            Fighter challengedFighter = System.Text.Json.JsonSerializer.Deserialize <Fighter>(FigherJson);

            string myFighterId = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(FigherJson).ChallengerFighterId;

            Fighter myFighter = _arena.Fighters().Where(x => x.id == myFighterId).First();


            using (IDbConnection dbConnection =
                       DbProviderFactories.GetFactory("system.data.sqlclient").CreateConnection())
            {
                dbConnection.ConnectionString = "Server=tcp:cipherrex.database.windows.net,1433;Initial Catalog=cipherRexUmbraco;Persist Security Info=False;User ID=cipherrex;Password=R00ksp@wnR00ksp@wn;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
                dbConnection.Open();
                Models.DAL.SqlDAL sqlDAL = new Models.DAL.SqlDAL(dbConnection);

                IPlayerRepo playerRepo = new PlayerRepo(sqlDAL);
                PlayerUoW   playerUoW  = new PlayerUoW(sqlDAL, playerRepo);

                playerUoW.updatePlayerBalance(myFighter.id, -10);
                playerUoW.updatePlayerBalance(challengedFighter.id, -10);
            }

            _combatManager.CreateCombatSession(myFighter, challengedFighter);

            //await _chatHubContext.AcceptChallenge(_userEmail, myFighter.ownerId, challengedFighter.ownerId, myFighter.id, challengedFighter.id);
            _chatHubContext.AcceptChallenge(_userEmail, myFighter.ownerId, challengedFighter.ownerId, myFighter.id, challengedFighter.id);
        }