public void CreateTournament(TournamentModel model) { List <TournamentModel> tournaments = TournamentFile.FullFilePath().LoadFile().ConvertToTournamentModels(TeamFile, PeopleFile, PrizesFile); //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(MatchupFile, MatchupEntryFile); tournaments.Add(model); tournaments.SaveToTournamentFile(TournamentFile); MessageBox.Show("Tournament added successfully"); }
private void Btn_createTournament_Click(object sender, RoutedEventArgs e) { decimal fee = 0; bool feeAcceptable = decimal.TryParse(Tbx_entryFeeValue.Text, out fee); if (!feeAcceptable) { MessageBox.Show("Please enter a valid Entry Fee"); return; } TournamentModel tm = new TournamentModel(); tm.TournamentName = Tbx_tournamentNameValue.Text; tm.EntryFee = fee; tm.Prizes = selectedPrizes; tm.EnteredTeams = selectedTeams; TournamentLogic.CreateRounds(tm); GlobalConfig.Connection[0].CreateTournament(tm); }