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); }
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)); } }
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)); }
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); }
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")); }
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)); }