private void SaveEnteredGameResults() { //Get results for each end game uc and update TableHockeyGame table. PlaceHolder PlaceHolder1 = (PlaceHolder)Page.Controls[0].FindControl("form1").FindControl("mainContent").FindControl("resultsRepeater").Controls[1].FindControl("PlaceHolder1"); for (int jCount = 0; jCount < PlaceHolder1.Controls.Count; jCount++) { uc.ucEndGameSeries ucCurrentEndGameSeries = (uc.ucEndGameSeries)PlaceHolder1.Controls[jCount]; ucCurrentEndGameSeries.getUCGUI(); for (int iCount = 0; iCount < ucCurrentEndGameSeries.m_games.Count; iCount++) { int currentHomeScoreEntered = ucCurrentEndGameSeries.m_games[iCount].HomePlayerScore; int currentAwayScoreEntered = ucCurrentEndGameSeries.m_games[iCount].AwayPlayerScore; int m_nCurrentGameId = ucCurrentEndGameSeries.m_games[iCount].GameId; int m_nCurrentHomePlayerId = ucCurrentEndGameSeries.m_games[iCount].HomePlayerId; int m_nCurrentAwayPlayerId = ucCurrentEndGameSeries.m_games[iCount].AwayPlayerId; bool m_bHasSuddenDeath = ucCurrentEndGameSeries.m_games[iCount].hasSuddenDeath; using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { var querySingleGame = context.TableHockeyGame.First(g => g.GameId == m_nCurrentGameId); TableHockeyGame m_currentGame = (TableHockeyGame)querySingleGame; m_currentGame.HomePlayerScore = currentHomeScoreEntered; m_currentGame.AwayPlayerScore = currentAwayScoreEntered; m_currentGame.hasSuddenDeath = m_bHasSuddenDeath; m_currentGame.HomePlayerId = m_nCurrentHomePlayerId; m_currentGame.AwayPlayerId = m_nCurrentAwayPlayerId; context.SaveChanges(); } } } }
public EndGameOverviewViewModel(TableHockeyGame i_game) { this.HomePlayerDescription = i_game.TableHockeyPlayer.FirstName + " " + i_game.TableHockeyPlayer.LastName; this.AwayPlayerDescription = i_game.TableHockeyPlayer1.FirstName + " " + i_game.TableHockeyPlayer1.LastName; this.HomePlayerId = i_game.TableHockeyPlayer.PlayerId; this.AwayPlayerId = i_game.TableHockeyPlayer1.PlayerId; this.PlayerDivider = " - "; this.ScoreDivider = this.PlayerDivider; }
private bool isPlayerOKToRemoveFromContest(int i_nPlayerId, int i_nContestId) { //Check for contest games for player. Also check that contest is still open. using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { TableHockeyGame m_tableHockeyGame = context.TableHockeyGame.FirstOrDefault(c => ((c.HomePlayerId == i_nPlayerId) || (c.AwayPlayerId == i_nPlayerId)) && (c.ContestId == m_nContestId)); TableHockeyContest m_tableHockeyContest = context.TableHockeyContest.First(c => c.ContestId == i_nContestId); return((m_tableHockeyGame == null) && (m_tableHockeyContest.ContestDateClosed.Equals(DateTime.Parse("1900-01-01")))); } }
public EndGameViewModel(TableHockeyGame i_game) { this.GameId = i_game.GameId; this.HomePlayerScore = (int)((i_game.HomePlayerScore != null) ? i_game.HomePlayerScore : -1); this.AwayPlayerScore = (int)((i_game.AwayPlayerScore != null) ? i_game.AwayPlayerScore : -1); this.HomePlayerScoreDescription = this.HomePlayerScore >= 0 ? Convert.ToString(this.HomePlayerScore) : ""; this.AwayPlayerScoreDescription = this.AwayPlayerScore >= 0 ? Convert.ToString(this.AwayPlayerScore) : ""; this.HomePlayerId = i_game.TableHockeyPlayer.PlayerId; this.AwayPlayerId = i_game.TableHockeyPlayer1.PlayerId; this.PlayerDivider = " - "; this.ScoreDivider = this.PlayerDivider; }
public GameViewModel(TableHockeyGame i_game) { this.GameId = i_game.GameId; this.HomePlayerScore = (int)((i_game.HomePlayerScore != null) ? i_game.HomePlayerScore : -1); this.AwayPlayerScore = (int)((i_game.AwayPlayerScore != null) ? i_game.AwayPlayerScore : -1); this.HomePlayerScoreDescription = this.HomePlayerScore >= 0 ? Convert.ToString(this.HomePlayerScore) : ""; this.AwayPlayerScoreDescription = this.AwayPlayerScore >= 0 ? Convert.ToString(this.AwayPlayerScore) : ""; this.HomePlayerDescription = i_game.TableHockeyPlayer.FirstName + " " + i_game.TableHockeyPlayer.LastName; this.AwayPlayerDescription = i_game.TableHockeyPlayer1.FirstName + " " + i_game.TableHockeyPlayer1.LastName; this.IdlePlayerDescription = i_game.TableHockeyPlayer2.FirstName + " " + i_game.TableHockeyPlayer2.LastName; this.HomePlayerId = i_game.TableHockeyPlayer.PlayerId; this.AwayPlayerId = i_game.TableHockeyPlayer1.PlayerId; this.IdlePlayerId = i_game.TableHockeyPlayer2.PlayerId; this.PlayerDivider = " - "; this.ScoreDivider = this.PlayerDivider; this.hasSuddenDeath = i_game.hasSuddenDeath; }
private void SaveEnteredGameResults() { //Get results for each row and update TableHockeyGame table. this.ucContestRound1.getUCGUI(); for (int iCount = 0; iCount < this.ucContestRound1.m_games.Count; iCount++) { int currentHomeScoreEntered = ucContestRound1.m_games[iCount].HomePlayerScore; int currentAwayScoreEntered = ucContestRound1.m_games[iCount].AwayPlayerScore; int m_nCurrentGameId = ucContestRound1.m_games[iCount].GameId; using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { var querySingleGame = context.TableHockeyGame.First(g => g.GameId == m_nCurrentGameId); TableHockeyGame m_currentGame = (TableHockeyGame)querySingleGame; m_currentGame.HomePlayerScore = currentHomeScoreEntered; m_currentGame.AwayPlayerScore = currentAwayScoreEntered; context.SaveChanges(); } } }
public static Dictionary <int, int> getPlayersToNextRound(TableHockeyContestRound i_enteredRound, int i_nGamesPerSeries) { int m_nNumberOfGamesToWinSeries = Convert.ToInt32((1 + i_nGamesPerSeries) / 2.0); Dictionary <int, int> m_dictPlayersToNextRound = new Dictionary <int, int>(); if (i_enteredRound.TableHockeyGame.Count > 0) { for (int m_nTableNumber = 1; m_nTableNumber <= PageUtility.m_nMaxNumberOfConcurrentGames; m_nTableNumber++) { int m_nHomeWon = 0; int m_nAwayWon = 0; var m_gamesForTable = i_enteredRound.TableHockeyGame.Where(g => g.TableNumber == m_nTableNumber); foreach (TableHockeyGame m_game in m_gamesForTable) { if ((m_game.AwayPlayerScore >= 0) && (m_game.HomePlayerScore >= 0)) { if (m_game.AwayPlayerScore > m_game.HomePlayerScore) { m_nAwayWon++; } if (m_game.HomePlayerScore > m_game.AwayPlayerScore) { m_nHomeWon++; } } } TableHockeyGame m_firstGame = m_gamesForTable.FirstOrDefault(); if (m_nAwayWon == m_nNumberOfGamesToWinSeries) { m_dictPlayersToNextRound.Add(m_firstGame.TableNumber, m_firstGame.AwayPlayerId); } if (m_nHomeWon == m_nNumberOfGamesToWinSeries) { m_dictPlayersToNextRound.Add(m_firstGame.TableNumber, m_firstGame.HomePlayerId); } } } return(m_dictPlayersToNextRound); }
private List <TableHockeyGame> getTableHockeyEndGameListForCurrentRound(TableHockeyContest i_contest, List <TableHockeyContestPlayer> i_contestPlayers) { //Get game list for end game. Always add full number of possible games per round. If a match series ends prematurely, games are returned as "scoreless". using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { var roundsQuery = from r in context.TableHockeyContestRound where r.ContestId == i_contest.ContestId select r; List <TableHockeyContestRound> m_lstTableHockeyRounds = (List <TableHockeyContestRound>)roundsQuery.ToList(); List <TableHockeyGame> m_lstTableHockeyGames = new List <TableHockeyGame>(); int m_nGamesPerRound = i_contest.numberOfRounds; DateTime m_dStartDate = DateTime.Now; //Create game list for current round. TableHockeyContestRound m_round = m_lstTableHockeyRounds[m_queueHandler.m_nCurrentRoundNumber - 1]; for (int k = 0; k < m_queueHandler.m_dictGamePlayersPerRound[m_queueHandler.m_nCurrentRoundNumber - 1].Count; k += 2) { for (int i = 0; i < m_nGamesPerRound; i++) { TableHockeyGame m_currentGame = new TableHockeyGame(); m_currentGame.ContestId = i_contest.ContestId; m_currentGame.GameStartDate = m_dStartDate; m_currentGame.isFinalGame = i_contest.isFinalGameContest; m_currentGame.TableNumber = (int)(k / 2.0) + 1; m_currentGame.TableHockeyContestRoundId = m_round.TableHockeyContestRoundId; m_currentGame.HomePlayerId = m_queueHandler.m_dictGamePlayersPerRound[m_queueHandler.m_nCurrentRoundNumber - 1].ElementAt(k).Key; m_currentGame.AwayPlayerId = m_queueHandler.m_dictGamePlayersPerRound[m_queueHandler.m_nCurrentRoundNumber - 1].ElementAt(k + 1).Key; m_currentGame.IdlePlayerId = -1; m_lstTableHockeyGames.Add(m_currentGame); } } return(m_lstTableHockeyGames); } }
//private int getLowerPlayerCountRotationLimit() //{ // using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) // { // var querySetting = context.Settings.First(s => s.SettingDescription == "INT_NUMBER_OF_PLAYERS_ROTATION_LOWER_LIMIT"); // return (int)querySetting.ValueInt; // } //} private List <TableHockeyGame> getTableHockeyGameList(TableHockeyContest i_contest, List <TableHockeyContestPlayer> i_contestPlayers) { using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { var roundsQuery = from r in context.TableHockeyContestRound where r.ContestId == i_contest.ContestId select r; List <TableHockeyContestRound> m_lstTableHockeyRounds = (List <TableHockeyContestRound>)roundsQuery.ToList(); List <TableHockeyGame> m_lstTableHockeyGames = new List <TableHockeyGame>(); int m_nGamesPerRound = getNumberOfGamesPerRound(i_contestPlayers.Count); DateTime m_dStartDate = DateTime.Now; PlayerViewModelList m_lstPlayerViewModel = new PlayerViewModelList(i_contestPlayers); TableHockeyQueueHandler2 m_queueHandler = new TableHockeyQueueHandler2(m_lstPlayerViewModel.m_lstContestPlayerId, m_nGamesPerRound); foreach (TableHockeyContestRound m_round in m_lstTableHockeyRounds) { for (int i = 0; i < m_nGamesPerRound; i++) { TableHockeyGame m_currentGame = new TableHockeyGame(); m_currentGame.ContestId = i_contest.ContestId; m_currentGame.GameStartDate = m_dStartDate; m_currentGame.isFinalGame = i_contest.isFinalGameContest; m_currentGame.TableNumber = i + 1; m_currentGame.TableHockeyContestRoundId = m_round.TableHockeyContestRoundId; m_currentGame.HomePlayerId = m_queueHandler.m_lstCurrentHomePlayerId[i]; m_currentGame.AwayPlayerId = m_queueHandler.m_lstCurrentAwayPlayerId[i]; m_currentGame.IdlePlayerId = m_queueHandler.getIdlePlayer(); m_lstTableHockeyGames.Add(m_currentGame); } m_queueHandler.nextRound(); } return(m_lstTableHockeyGames); } }