public ActionResult JoinTable(string gameTableID) { GameTable foundGt = null; bool userFound = false; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); if (gameTableID != null) { string userId = User.Identity.GetUserId(); int tableId = Int32.Parse(gameTableID); foundGt = gameTableServiceAcces.GetGameTable(tableId); foreach (var user in foundGt.Users) { if (user.Id == userId) { userFound = true; } } if (foundGt.Users.Count == 4 && !userFound) { return(View("JoinTable")); } try { foundGt = gameTableServiceAcces.JoinGameTable(userId, tableId); } catch (Exception e) { return(RedirectToAction("Error", "ErrorHandler", new { id = 3 })); } } List <GameTable> tables = new List <GameTable>() { foundGt }; return(RedirectToAction("Lobby", new { tableId = foundGt.Id })); }
public void DeleteTest() { //Arrange GameTableServiceAccess gameTableServiceAccess = new GameTableServiceAccess(); CGUserModel userModel = new CGUserModel { Id = "Test", Email = "*****@*****.**", UserName = "******" }; GameTableModel tableModel = null; gameTableServiceAccess.CreateGameTable(userModel, "TestTable"); List <GameTableModel> tables = gameTableServiceAccess.GetAll(); foreach (var table in tables) { if (table.TableName == "TestTable") { tableModel = table; } } bool res = false; //Act res = gameTableServiceAccess.Delete(tableModel.Id); //Assert Assert.IsTrue(res); }
public ActionResult Lobby(int?tableId) { GameTable foundGt = null; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); foundGt = gameTableServiceAcces.GetGameTable((int)tableId); return(View(foundGt)); }
// GET: Table public ActionResult Index() { List <GameTable> gameTables; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); ViewBag.Situation = 0; gameTables = gameTableServiceAcces.GetAll(); return(View(gameTables)); }
public void GetAllTest() { //Arrange GameTableServiceAccess gameTableServiceAccess = new GameTableServiceAccess(); //Act List <GameTableModel> gameTables = gameTableServiceAccess.GetAll(); //Assert Assert.IsTrue(gameTables.Count > 0); }
// GET: Game public ActionResult Index(int id) { GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); GameServiceAcces gameServiceAccess = new GameServiceAcces(); Game game = null; try { GameTable gameTable = gameTableServiceAcces.GetGameTable(id); game = gameServiceAccess.StartGame(gameTable); } catch (Exception e) { return(RedirectToAction("Error", "ErrorHandler", new { id = 2 })); } return(View(game)); }
public void GetByIdTest() { //Arrange GameTableServiceAccess gameTableServiceAccess = new GameTableServiceAccess(); GameTableModel gameTable = null, gameTable2 = null; List <GameTableModel> tables = gameTableServiceAccess.GetAll(); if (tables.Count > 0) { gameTable = tables[0]; } //Act gameTable2 = gameTableServiceAccess.GetById(gameTable.Id); //Assert Assert.AreEqual(gameTable.TableName, gameTable2.TableName); }
public ActionResult Create(string tableName) { GameTable foundGt = null; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); if (tableName != null) { string userId = User.Identity.GetUserId(); try { foundGt = gameTableServiceAcces.CreateGameTable(userId, tableName); }catch (Exception e) { return(RedirectToAction("Error", "ErrorHandler", new { id = 4 })); } } ViewBag.Situation = 3; return(RedirectToAction("Lobby", new { tableId = foundGt.Id })); }
public ActionResult Index(string InputTableName) { GameTable foundGt = null; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); if (InputTableName != null) { foundGt = gameTableServiceAcces.GetTableByName(InputTableName); } List <GameTable> tables = new List <GameTable>() { foundGt }; ViewBag.Situation = 2; return(View(tables)); }