private void TECreateTournamentButton_Click(object sender, EventArgs e) { if (ValidateForm()) { TournamentModel t = new TournamentModel(); t.TournamentName = TENameTextBox.Text; t.TeamsEntered = selectedTeams; string formattedStartDateTime = TEStartDatePicker.Value.Year.ToString() + "-" + TEStartDatePicker.Value.Month.ToString() + "-" + TEStartDatePicker.Value.Day.ToString() + " " + TEScheduleGamesStartPicker.Value.Hour.ToString() + ":" + TEScheduleGamesStartPicker.Value.Minute.ToString(); string formattedEndDateTime = TEEndDatePicker.Value.Year.ToString() + "-" + TEEndDatePicker.Value.Month.ToString() + "-" + TEEndDatePicker.Value.Day.ToString() + " " + TEScheduleGamesEndPicker.Value.Hour.ToString() + ":" + TEScheduleGamesEndPicker.Value.Minute.ToString(); DateTime StartTime = Convert.ToDateTime(formattedStartDateTime); DateTime EndTime = Convert.ToDateTime(formattedEndDateTime); MessageBox.Show(StartTime.ToString()); t.TournamentDateStart = StartTime; t.TournamentDateEnd = EndTime; //var tournamentSwitch = TEStageOneComboBox.SelectedIndex; //switch (tournamentSwitch) //{ // case 0: // t.Format = tournamentSwitch; // TournamentSingleElimination.CreateRounds(t); // break; // case 1: // t.Format = tournamentSwitch; // TournamentDoubleElimination.CreateRounds(t); // break; // case 2: // t.Format = tournamentSwitch; // TournamentRoundRobin.CreateRounds(t); // break; // case 3: // t.Format = tournamentSwitch; // TournamentSwiss.CreateRounds(t); // break; // default: // MessageBox.Show("Please choose a format!"); // break; //}; TournamentRoundRobin.CreateRounds(t); GlobalConfiguration.Connection.CreateTournament(t); t.AlertPlayersToNewRound(); TournamentViewer form = new TournamentViewer(t); form.Show(); Close(); } }
public ActionResult EditLeague(TournamentDetailsMvcModel model, string listOfTeams) { TournamentModel t = new TournamentModel { Id = model.Id }; t = GlobalConfiguration.Connection.Tournaments_GetByID(t.Id); t.TournamentName = model.TournamentName; t.Active = model.Active; t.TeamsEntered = model.TeamsEntered; t.TournamentStartDate = model.TournamentDateStart.Add(model.TournamentTimeStart); t.TournamentEndDate = model.TournamentDateEnd.Add(model.TournamentTimeEnd); int divisionsToAdd = Int32.Parse(model.DivisionsToAdd); int divisionsToRemove = Int32.Parse(model.DivisionsToRemove); int numberOfDivisions = t.DivisionsEntered.Count; string[] split = listOfTeams.Split(new[] { ']' }, StringSplitOptions.RemoveEmptyEntries); string[] split3 = Regex.Split(split[t.DivisionsEntered.Count], @"\D+"); SeedTeams(t, split, split3); AdjustDivisionSize(t, divisionsToAdd, divisionsToRemove, numberOfDivisions); GlobalConfiguration.Connection.EditTournament(t); if (t.Active) { GlobalConfiguration.Connection.TeamGroup_Insert(t.DivisionsEntered); t.DivisionsEntered = GlobalConfiguration.Connection.TeamGroupEntries_GetSpecific(t.DivisionsEntered); foreach (DivisionModel dm in t.DivisionsEntered) { foreach (GroupModel gm in dm.Groups) { TournamentRoundRobin.CreateRounds(gm); GlobalConfiguration.Connection.SaveGroupRounds(gm, t.Id); } } } return(RedirectToAction("DetailLeague", "Tournament", new { id = model.Id })); }