public void AcceptUserInvite(string myId, string invitedUserId, string rows, string cols, int turnamentid = -1) { DateTime dateTime = DateTime.Now; string gameId = dateTime.Ticks.ToString(); GameTables gameTable = new GameTables(); gameTable.UserInTurn = myId; gameTable.GameId = gameId; gameTable.Rows = int.Parse(rows); gameTable.Cols = int.Parse(cols); gameTable.TurnamentId = turnamentid.ToString(); context.GameTables.Add(gameTable); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 2 * gameTable.Rows + 1; i++) { for (int j = 0; j < 2 * gameTable.Cols + 1; j++) { string cell = i + "-" + j + "-0,"; sb.Append(cell); } } MoveTable moveRecord = new MoveTable(); moveRecord.TableId = gameId; moveRecord.UserId = myId; sb.Length--; moveRecord.Board = sb.ToString(); moveRecord.TimeMove = DateTime.Now; context.MoveTables.Add(moveRecord); context.SaveChanges(); Clients.All.acceptInvite(myId, invitedUserId, rows, cols, gameId); }
private void NewState(string cellId, string gameId, string userInTurn, StringBuilder newBoardState) { MoveTable nmm = new MoveTable(); nmm.TableId = gameId; nmm.UserId = userInTurn; nmm.Board = newBoardState.ToString(); nmm.CellTaken = cellId; nmm.TimeMove = DateTime.Now; context.MoveTables.Add(nmm); context.SaveChanges(); }