Ejemplo n.º 1
0
        public ActionResult MoneyReset()
        {
            string username = (string)Session["username"];

            UserSqlDal dal = new UserSqlDal();

            dal.UpdateMoney(username, 1000);

            return(View("MoneyReset"));
        }
Ejemplo n.º 2
0
        public ActionResult TakeSeat(UserAndTable model)
        {
            int    tableID    = model.Table.TableID;
            string userName   = model.User.Username;
            int    MoneyAdded = model.MoneyToTheTable;

            int MaxBuyIn = model.Table.MaxBuyIn;

            UserSqlDal uDal      = new UserSqlDal();
            UserModel  user      = uDal.GetUserByUserName(userName);
            int        UserMoney = user.CurrentMoney;

            TableSqlDal dal = new TableSqlDal();

            if (MoneyAdded <= UserMoney && MoneyAdded <= MaxBuyIn && MoneyAdded > 0)
            {
                int newMoneyValue = UserMoney - MoneyAdded;

                uDal.UpdateMoney(userName, newMoneyValue);

                bool isAdded = dal.AddPlayerToTable(tableID, userName, MoneyAdded);

                dal.InsertIntoHandSeat(tableID, dal.GetHandID(tableID), userName);
                return(RedirectToAction("JoinedTable", "Game", new { id = tableID }));
            }
            else
            {
                Table        table = dal.FindTable(tableID);
                UserAndTable ut    = new UserAndTable();
                ut.Table      = table;
                ut.User       = user;
                ut.WasFailure = true;

                return(View("TakeSeat", ut));
            }
        }