public ActionResult SwitchSetting(int setting)
        {
            bool didWork    = _dal.SwitchSettings(setting);
            var  jsonResult = Json(new Game()
            {
                GameID = 1
            }, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
        public ActionResult Settings(Settings model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Settings"));
            }
            var setting = _dal.SwitchSettings(1);
            var myGame  = _dal.Setup(model);
            var didWork = _dal.SetGame(model);


            return(RedirectToAction("Game"));
        }
Ejemplo n.º 3
0
        public ActionResult Login(LoginViewModel model)
        {
            ActionResult result = null;

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception();
                }

                UserItem user = null;
                try
                {
                    user = _dal.GetUserItem(model.Username);
                }
                catch (Exception)
                {
                    ModelState.AddModelError("invalid-user", "Either the username or the password is invalid.");
                    throw;
                }

                PasswordHelper passHelper = new PasswordHelper(model.Password, user.Salt);
                if (!passHelper.Verify(user.Hash))
                {
                    ModelState.AddModelError("invalid-user", "Either the username or the password is invalid.");
                    throw new Exception();
                }

                // Happy Path
                base.LogUserIn(user);
                string isSetting = _dal.CheckSetting();
                if (isSetting == "0")
                {
                    bool okay = _dal.SwitchSettings(2);
                    result = RedirectToAction("Settings", "StockGame");
                }
                else
                {
                    result = RedirectToAction("Game", "StockGame");
                }
            }
            catch (Exception)
            {
                result = View("Login");
            }

            return(result);
        }