/// <summary> /// Save a tournament to the text file /// </summary> /// <param name="model"></param> public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentsFile .FullFilePath() .LoadFile() .ConvertToTournamentModels(); // Find the max ID and add 1 to it int currentId = 1; if (tournaments.Count > 0) { currentId = tournaments.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; // Populate matchup ids model.SaveRoundsToFile(); tournaments.Add(model); tournaments.SaveToTournamentsFile(); TournamentLogic.UpdateTournamentResults(model); }
private void createTournamentButton_Click(object sender, EventArgs e) { decimal fee = 0; bool validateFee = decimal.TryParse(entryFeeValue.Text, out fee); if (!validateFee) { MessageBox.Show("Enter valid fee", "invalid fee", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TournamentModel tm = new TournamentModel(); tm.TournamentName = tournamentNameValue.Text; tm.EntryFee = fee; tm.Prizes = selectedPrizes; tm.teamModels = selectedTeams; TournamentLogic.CreateRounds(tm); GlobalConfig.Connection.CreateTournament(tm); tm.AlertUsersToNewRound(); TournamentViewerForm form = new TournamentViewerForm(tm); form.Show(); this.Close(); }
public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile .FullFilePath() .LoadFile() .ConvertToTournamentModels(); // Find the max Id int currentId = 1; if (tournaments.Count > 0) { currentId = tournaments.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; model.SaveRoundsToFile(); // Add the new record with the new Id (max + 1) tournaments.Add(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); }
public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile .FullFilePath() .LoadFile() .ConvertToTournamentModels(); // Find the max ID int currentId = 1; if (tournaments.Count > 0) { currentId = tournaments.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; // Loop through every round and then every machup and save both the machup and the machup entries model.SaveRoundsToFile(); tournaments.Add(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); }
private void createTournamentButton_Click(object sender, EventArgs e) { // Validate the data in the form if (ValidationHelper.ValidateTournamentForm(out string errorMessage, tournamentNameValue.Text, _selectedEntries)) { // Create the TournamentModel TournamentModel tournament = new TournamentModel { TournamentName = tournamentNameValue.Text, TournamentEntries = _selectedEntries, CurrentRound = 0 }; // Wire up matchups TournamentLogic.CreateRounds(tournament); // Create Tournament entry // Create all TournamentEntries GlobalConfig.Connection.CreateTournament(tournament); // Handle bye matchups TournamentLogic.HandleByeMatchups(tournament); // Open the TournamentViewerForm and close this form TournamentViewerForm form = new TournamentViewerForm(tournament); form.Show(); Close(); } else { // Show error message MessageBox.Show($"The following errors exist in the form:\n{ errorMessage }", "Creation error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CreateTournamentButton_Click(object sender, EventArgs e) { //first - create tournament model decimal fee = 0; bool feeAcceptable = decimal.TryParse(EntryFeeTextBox.Text, out fee); if (!feeAcceptable) { MessageBox.Show("Please Enter Valied Amount For Entry Fee ", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); return; } // List<TournamentModel> tm = new List<TournamentModel>(); TournamentModel t = new TournamentModel(); t.TournamentName = scoreTextBox.Text; t.EntreyFee = fee; t.Prizes = selectedPrize; t.EntredTeam = selectedTeam; //TODO - Wire our matchup TournamentLogic.CreateRound(t); GlobalConfig.connection.createTournamnet(t); //foreach (PrizeModel prize in selectedPrize) { // t.Prizes.Add(prize); //} //create tournament Entery //create all of the prize enries //create all of the team entry }
// 這邊我用 void 因為instances 不需要來回傳送新資料, 如果有兩個地方有用到這個 只要改動一邊 那麼另一邊也會自動更新 // instances passed don't have to pass back and forth, once they have been two different locations you can modify either location and they both are updated. public void CreateTournament(TournamentModel model) { List <TournamentModel> tournament = GlobalConfig.TournamentFile .FullFilePath() .LoadFile() .ConvertToTournamentModels(); int currentId = 1; if (tournament.Count > 0) { currentId = tournament.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; // 在存入tournament 之前 我們要像SQL 一樣把裡面Id對應的model 都存入個別的file裡 model.SaveRoundsToFile(); tournament.Add(model); tournament.SaveToTournamentFile(); // 在我們Create tournament 上傳到sql/Textfile之後 我們要把每個bye moved into the next round TournamentLogic.UpdateTournamentResults(model); }
public void DetermineNewTournamentState_WhenBellStateMatrixAvailable() { // Arrange var tournamentRepositoryFake = new Mock <ITournamentRepository>(); var mapper = Helper.SetupMapper(); var gameLogicFake = new Mock <IGameLogic>(); ITournamentLogic tournamentLogic = new TournamentLogic(tournamentRepositoryFake.Object, gameLogicFake.Object); Tournament tournament = new Tournament { BellCounter = 0, BellStateLookupMatrix = new List <BellStateLookup> { new BellStateLookup { BellCounter = 1, State = TournamentState.PrePlay }, new BellStateLookup { BellCounter = 2, State = TournamentState.PrePlay }, new BellStateLookup { BellCounter = 3, State = TournamentState.InPlay } } }; // Act var newState = tournamentLogic.AddBell(tournament); // Assert Assert.Equal(TournamentState.PrePlay, newState.State); }
public void SetTournamentBellCounter() { // Arrange var tournamentRepositoryFake = new Mock <ITournamentRepository>(); var mapper = Helper.SetupMapper(); var gameLogicFake = new Mock <IGameLogic>(); ITournamentLogic tournamentLogic = new TournamentLogic(tournamentRepositoryFake.Object, gameLogicFake.Object); Tournament tournament = new Tournament { BellCounter = 0, BellStateLookupMatrix = new List <BellStateLookup> { new BellStateLookup { BellCounter = 1, State = TournamentState.PrePlay }, new BellStateLookup { BellCounter = 2, State = TournamentState.PrePlay }, new BellStateLookup { BellCounter = 3, State = TournamentState.InPlay } } }; // Act tournamentLogic.AddBell(tournament); // Assert Assert.NotEqual(0, tournament.BellCounter); }
public void CreateTournament() { // Create our tournament model TournamentModel tm = new TournamentModel { TournamentName = TournamentName, EntryFee = EntryFee, Prizes = SelectedPrizes.ToList(), EnteredTeams = SelectedTeams.ToList() }; // TODO - Wire our matchups TournamentLogic.CreateRounds(tm); // Create Tournament entry // Create all of the prizes entries // Create all of the teams entries GlobalConfig.Connection.CreateTournament(tm); tm.AlertUsersToNewRound(); EventAggregationProvider.TrackerEventAggregator.PublishOnUIThread(tm); TryClose(); }
/// <summary> /// to add data into TournamentModel.csv /// </summary> /// <param name="model"></param> public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile.FullFilePath() .LoadFile() .ConvertToTournamentModels(); int currentId = 1; if (tournaments.Count > 0) { currentId = tournaments.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; model.SaveRoundsToFile(); //tournaments.SaveRoundsToFile(model, MatchupFile, MatchupEntryFile); tournaments.Add(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); }
public void SetPreplayGame_WhenInNoPlayAndNewPreplayGameCreated() { // Arrange var tournamentRepositoryMock = new Mock <ITournamentRepository>(); var mapper = Helper.SetupMapper(); var gameLogicFake = new Mock <IGameLogic>(); Guid newPreplayGameId = new Guid(); gameLogicFake.Setup(m => m.BuildGame(It.IsAny <Guid>(), It.IsAny <int>())).Returns(new Game { Id = newPreplayGameId }); ITournamentLogic tournamentLogic = new TournamentLogic(tournamentRepositoryMock.Object, gameLogicFake.Object); // Act Tournament t = tournamentLogic.SetPreplay(new Tournament { Id = new Guid(), PreplayGameId = null, InplayGameId = null, PostplayGameId = null, CluesPerGame = 1 }, out Game newPreplayGame); // Assert Assert.Equal(t.PreplayGameId, newPreplayGameId); }
public ActionResult Create(TournamentMVCCreateModel model) { try { if (ModelState.IsValid && model.SelectedEnteredTeams.Count > 0) { List <PrizeModel> allPrizes = GlobalConfig.Connection.GetPrizes_All(); List <TeamModel> allTeams = GlobalConfig.Connection.GetTeam_All(); TournamentModel t = new TournamentModel(); t.TournamentName = model.TournamentName; t.EntryFee = model.EntryFee; t.EnteredTeams = model.SelectedEnteredTeams.Select(x => allTeams.Where(y => y.Id == int.Parse(x)).First()).ToList(); t.Prizes = model.SelectedPrizes.Select(x => allPrizes.Where(y => y.Id == int.Parse(x)).First()).ToList(); //Wire our matchups TournamentLogic.CreateRounds(t); GlobalConfig.Connection.CreateTournament(t); t.AlertUsersToNewRound(); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Create")); } } catch (Exception ex) { return(View()); } }
private void CreateTournamentButton_Click(object sender, System.EventArgs e) { bool feeAcceptable = decimal.TryParse(EntryFeeValue.Text, out var fee); if (!feeAcceptable) { MessageBox.Show("Please enter rightly sum of fee", "Wrong fee entered", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TournamentModel tournament = new TournamentModel(); tournament.TournamentName = TournamentNameValue.Text; tournament.EnrtyFee = fee; tournament.Prizes = prizes; tournament.EnteredTeams = selectedTeams; TournamentLogic.CreateRounds(tournament); GlobalConfig.Connections.CreateTournament(tournament); tournament.AlertUsersToNewRound(); TournamentViewForm tform = new TournamentViewForm(tournament); tform.Show(); this.Close(); }
private void CreateTournamentButton_Click(object sender, EventArgs e) { if (TournamentNameValue.Text.Length == 0) { MessageBox.Show("Please enter a tournament name."); return; } // Verify that team & prize lists aren't empty? decimal fee = 0; bool feeAcceptable = decimal.TryParse(EntryFeeValue.Text, out fee); if (!feeAcceptable) { MessageBox.Show("Please enter a valid entry fee.", "Invalid Fee", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TournamentModel tournament = new TournamentModel(); tournament.TournamentName = TournamentNameValue.Text; tournament.EntryFee = fee; tournament.Prizes = selectedPrizes; tournament.EnteredTeams = selectedTeams; TournamentLogic.CreateRounds(tournament); GlobalConfig.Connection.CreateTournament(tournament); this.Close(); }
public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile.FullFilePath().LoadFile().ConvertToTournamentModels(); int CurrentId = 1; if (tournaments.Count > 0) { CurrentId = tournaments.OrderByDescending(team => team.Id).First().Id + 1; } model.Id = CurrentId; model.SaveRoundsToFile(); model.DateCreated = DateTime.Now; tournaments.Add(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); //return model; }
private void buttonStvori_turnir_Click(object sender, EventArgs e) { decimal fee; bool feeAcceptable = decimal.TryParse(textBoxNagrada.Text, out fee); if (!feeAcceptable) { MessageBox.Show("Moraš upisati pravilnu kotizaciju", "Netočna kotizacija", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TurnirModel tm = new TurnirModel(); tm.TournamentName = ime_turn.Text; tm.EntryFee = fee; tm.EntredTeams = selectedTeams; foreach (NagradaModel prize in selectedPrizes) { tm.Prizes.Add(prize); } TournamentLogic.CreateRounds(tm); GlobalConfig.Connection.CreateTournament(tm); DashboardForm frm = new DashboardForm(tm); frm.Show(); this.Close(); }
private void createTournamentButton_Click(object sender, EventArgs e) { if (!ValidateForm()) //Validate data { return; } TournamentModel tm = new TournamentModel(); //Create Tournament model tm.TournamentName = tournamentNameValue.Text; tm.EntryFee = decimal.Parse(entryFeeValue.Text); tm.Prizes = selectedPrizes; //Create all of the prizes entries tm.EnteredTeams = selectedTeams; //Create all of team entries TournamentLogic.CreateRounds(tm); //Wire the matchups GlobalConfig.Connection.CreateTournament(tm); TournamentViewerForm form = new TournamentViewerForm(tm); form.Show(); this.Close(); }
public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile .FullFilePath() .LoadFile() .ConvertToTournamentModels(); // Find MAX Id based on the file read, if file is empty then assign id = 1 int currentId = 1; if (tournaments.Count > 0) { currentId = tournaments.OrderByDescending(x => x.Id).First().Id + 1; } model.Id = currentId; model.SaveRoundsToFile(); tournaments.Add(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); }
private void createTournamentButton_Click(object sender, EventArgs e) { //Validate data if (ValidateForm()) { //Create our tournament model TournamentModel tm = new TournamentModel(); tm.TournamentName = tournamentNameValue.Text; tm.EntryFee = decimal.Parse(entryFeeValue.Text); tm.Prizes = selectedPrizes; tm.EnteredTeams = selectedTeams; // Wire up matchups TournamentLogic.CreateRounds(tm); //Create tournament entry, using tournamentName, EntryFee, //Create all of the prizes entries //Create all of the team entries GlobalConfig.Connection.CreateTournament(tm); tm.AlertUsersToNewRound(); TournamentLogic.UpdateTournamentResults(tm); TournamentViewer frm = new TournamentViewer(tm); frm.Show(); callingForm.TournamentComplete(tm); Close(); } }
private void buttonScore_Click(object sender, EventArgs e) { string errorMessage = ValidData(); if (errorMessage.Length > 0) { MessageBox.Show($"Imput error:{errorMessage}"); return; } UtakmicaModel m = (UtakmicaModel)listBoxMatchups.SelectedItem; double teamOneScore = 0; double teamTwoScore = 0; for (int i = 0; i < m.Entries.Count; i++) { if (i == 0) { if (m.Entries[0].TeamCompeting.TeamName != null) { bool scoreValid = double.TryParse(textBoxRezultat1.Text, out teamOneScore); if (scoreValid) { m.Entries[0].Score = double.Parse(textBoxRezultat1.Text); } else { MessageBox.Show("Pelase enter a valid score for team 1"); return; } } } if (i == 1) { if (m.Entries[1].TeamCompeting.TeamName != null) { bool scoreValid = double.TryParse(textBoxRezultat2.Text, out teamTwoScore); if (scoreValid) { m.Entries[1].Score = double.Parse(textBoxRezultat2.Text); } else { MessageBox.Show("Pelase enter a valid score for team 2"); return; } } } } try { TournamentLogic.UpdateTournamentResults(tournament); } catch (Exception ex) { MessageBox.Show($"Aplication has the following error:{ex.Message}"); } LoadMatchups((int)comboBoxRunde.SelectedItem); }
public void CompleteTournament(TournamentModel model) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile.FullFilePath().LoadFile().ConvertToTournamentModels(); tournaments.Remove(model); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(model); }
public void CompleteTournament(TournamentModel tournament) { List <TournamentModel> tournaments = GlobalConfig.TournamentFile.FullFilePath().LoadFile().ConvertToTournamentModels(GlobalConfig.TournamentFile, GlobalConfig.PeopleFile, GlobalConfig.PrizesFile); tournaments.Remove(tournament); tournaments.SaveToTournamentFile(); TournamentLogic.UpdateTournamentResults(tournament); }
private void scoreButton_Click(object sender, EventArgs e) { MatchupModel m = (MatchupModel)matchupListBox.SelectedItem; double teamOneScore = 0; double teamTwoScore = 0; for (int i = 0; i < m.Entries.Count; i++) { if (i == 0) { if (m.Entries[0].TeamCompeting != null) { bool scoreValid = double.TryParse(teamOneScoreValue.Text, out teamOneScore); if (scoreValid) { m.Entries[0].Score = teamOneScore; } else { MessageBox.Show("Please enter a valid score for team 1."); return; } } } if (i == 1) { if (m.Entries[1].TeamCompeting != null) { bool scoreValid = double.TryParse(teamTwoScoreValue.Text, out teamTwoScore); if (scoreValid) { m.Entries[1].Score = teamTwoScore; } else { MessageBox.Show("Please enter a valid score for team 2."); return; } } } } try { TournamentLogic.UpdateTournamentResults(tournament); } catch (Exception ex) { MessageBox.Show($"The application had the following error: {ex.Message}"); } LoadMatchups(); WireUpMatchupsLists(); }
public void CreateTournament(TournamentModel tournament) { using (IDbConnection connection = new SqlConnection(GlobalConfig.ConnectionString(dbName))) { SaveTournament(connection, tournament); SaveTournamentPrizes(connection, tournament); SaveTournamentTeams(connection, tournament); SaveTournamentsRounds(connection, tournament); TournamentLogic.UpdateTournamentResults(tournament); } }
public void CreateTournament(TournamentModel model) { using (IDbConnection connection = new SqlConnection(CM.ConnectionStrings["Tournaments"].ConnectionString)) { SaveTournament(connection, model); SaveTournamentPrizes(connection, model); SaveTournamentEntries(connection, model); SaveTournamentRounds(connection, model); TournamentLogic.UpdateTournamentResults(model); } }
public void CreateTournament(TournamentModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) { SaveTournament(model, connection); SaveTournamentPrizes(model, connection); SaveTournamentEntries(model, connection); SaveTournamentRounds(model, connection); TournamentLogic.UpdateTournamentResults(model); } }
/// <summary> /// to create the database to create a tournament and save individual data to corresponding tables. /// </summary> /// <param name="model"></param> public void CreateTournament(TournamentModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) { // below is the code to connect with the sql server database. SaveTournament(connection, model); SaveTournamentPrizes(connection, model); SaveTournamentEntries(connection, model); SaveTournamentRounds(connection, model); TournamentLogic.UpdateTournamentResults(model); } }
private void updateScoreButton_Click(object sender, EventArgs e) { MatchupModel matchup = (MatchupModel)matchupsListBox.SelectedItem; // Validate the data in the form if (ValidationHelper.ValidateUpdateScoreForm(out string errorMessage, entryOneScoreValue.Text, entryTwoScoreValue.Text)) { // Update tournament TournamentLogic.UpdateTournament(_activeTournament, matchup, entryOneScoreValue.Text, entryTwoScoreValue.Text); LoadMatchups(showUnplayedOnlyCheckBox.Checked); }
private void createTournamentButton_Click(object sender, EventArgs e) { if (ValidateForm()) { TournamentModel tm = new TournamentModel(); tm.TournamentName = tournamentNameValue.Text; tm.EntryFee = decimal.Parse(entryFeeValue.Text); tm.EnteredTeams = selectedTeams; tm.Prizes = selectedPrizes; TournamentLogic.CreateRounds(tm); GlobalConfig.Connection.CreateTournament(tm); } }