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 ActionResult Lobby(int?tableId) { GameTable foundGt = null; GameTableServiceAccess gameTableServiceAcces = new GameTableServiceAccess(); foundGt = gameTableServiceAcces.GetGameTable((int)tableId); return(View(foundGt)); }
// 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)); }