Exemple #1
0
        public void UpdateGameAccountStats()
        {
            UserLogicTest.InsertUser(new User()
            {
                Username = "******",
                Email    = "*****@*****.**",
                Password = "******"
            });

            var user = UserLogicTest.AuthenticatUser("Mies", "123");

            var gameaccount = GameAccountTest.GetAccountByID(user.Id);
            int oldslayer   = gameaccount.Slayer;

            GameAccountTest.UpdateStats(new GameAccount()
            {
                Id       = gameaccount.Id,
                Name     = gameaccount.Name,
                Kind     = gameaccount.Kind,
                Attack   = gameaccount.Attack,
                Defence  = gameaccount.Defence,
                Strength = gameaccount.Strength,
                Slayer   = gameaccount.Slayer + 1
            });

            var gameaccountNew = GameAccountTest.GetAccountByID(user.Id);

            Assert.AreNotEqual(oldslayer, gameaccountNew.Slayer);
        }
        public ActionResult UpdateAccountStats(UpdateGameAccountViewModel updatedAccount)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("UpdateStatsPage", "Stats"));
            }

            GameAccount account = new GameAccount
            {
                Id       = (int)HttpContext.Session.GetInt32("id"),
                Name     = updatedAccount.Name,
                Attack   = updatedAccount.Attack,
                Defence  = updatedAccount.Defence,
                Strength = updatedAccount.Strength,
                Slayer   = updatedAccount.Slayer
            };

            AccountLogic.UpdateStats(account);
            return(RedirectToAction("Stats", "Stats"));
        }