Exemplo n.º 1
0
        public void TestLoginFail()
        {
            UserSqlDal dal = new UserSqlDal();
            UserModel  a   = dal.Login("Boa");
            UserModel  b   = dal.Login("arglefargle");
            UserModel  c   = dal.Login("Bo");

            Assert.IsNull(a);
            Assert.IsNull(b);
            Assert.IsNull(c);
            //Assert.AreNotEqual(50000, a.CurrentMoney);
            //Assert.AreNotEqual("admin", a.Privilege);
        }
Exemplo n.º 2
0
        public ActionResult CreateTable(Table model)
        {
            if (model.Ante >= 0 && model.MinBet > 0 && model.MaxBet >= model.MinBet && model.MaxBuyIn >= model.MinBet)
            {
                model.TableHost = (string)Session["UserName"];

                model.Pot = 0;

                TableSqlDal dal   = new TableSqlDal();
                int         newID = dal.CreateTable(model);

                Table output = dal.FindTable(newID);

                UserSqlDal userDal     = new UserSqlDal();
                UserModel  currentUser = userDal.Login(model.TableHost);

                UserAndTable ut = new UserAndTable();
                ut.Table = output;
                ut.User  = currentUser;

                return(View("TakeSeat", ut));
            }
            else
            {
                Table t = new Table();
                t.Ante = 5;
                return(View("CreateTable", t));
            }
        }
Exemplo n.º 3
0
        public ActionResult Login(UserModel user)
        {
            UserSqlDal dal          = new UserSqlDal();
            UserModel  existingUser = dal.Login(user.Username);

            if (existingUser == null)
            {
                user.LoginFail = true;
                return(View("Login", user));
            }

            HashProvider provider = new HashProvider();

            if (user.LoginPassword != null && provider.VerifyPasswordMatch(existingUser.Password, user.LoginPassword, existingUser.Salt))
            {
                user.LoginFail      = false;
                user.IsOnline       = true;
                Session["user"]     = user;
                Session["username"] = user.Username;
                return(RedirectToAction("LoggedInLanding", "Home"));
            }

            user.LoginFail = true;
            return(View("Login", user));
        }
Exemplo n.º 4
0
        public void TestLoginSuccess()
        {
            UserSqlDal dal = new UserSqlDal();
            UserModel  a   = dal.Login("Bob");

            Assert.AreEqual(50000, a.CurrentMoney);
            Assert.AreEqual("admin", a.Privilege);
            Assert.AreEqual("pwd2", a.Password);
        }
Exemplo n.º 5
0
        public ActionResult LeaveTable()
        {
            string userName = (string)Session["Username"];
            int    tableID  = 0;

            UserSqlDal uDal = new UserSqlDal();
            UserModel  user = uDal.Login(userName);

            tableID = uDal.GetTableByPlayer(userName);

            TableSqlDal tDal  = new TableSqlDal();
            Table       table = tDal.FindTable(tableID);

            tDal.LeaveTable(userName, tableID);

            user = uDal.Login(userName);

            if (user.CurrentMoney < 100)
            {
                return(RedirectToAction("MoneyReset", "User"));
            }

            return(RedirectToAction("LoggedInLanding", "Home"));
        }
Exemplo n.º 6
0
        public ActionResult SitAtTable(int TableID)
        {
            TableSqlDal dal     = new TableSqlDal();
            UserSqlDal  userDal = new UserSqlDal();

            string username = (string)Session["Username"];

            UserModel currentUser = userDal.Login(username);
            Table     table       = dal.FindTable(TableID);

            UserAndTable ut = new UserAndTable();

            ut.Table = table;
            ut.User  = currentUser;

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