public static void doIt(string sched) { Schedule schedule = new Schedule(sched); // ***********PAUL CHANGE SQL STRING TO PARAMETERIZED COMMAND!!!******* // https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlcommand.parameters?redirectedfrom=MSDN&view=netframework-4.7.2#System_Data_SqlClient_SqlCommand_Parameters //--------------------------------------------------- // Insert the SCHEDULE into the DB int scheduleID = ScheduleData.InsertSchedule(schedule); int i = 0; //--------------------------------------------------- //--------------------------------------------------- // Insert the list of GAMEs into the DB // INCLUDES: Insert the TEAMs (insert the CONFERENCE, DIVISION, VENUE), VENUE, list of PERIODs, BOXSCOREs(insert the TEAMGAMESTATS(insert the PERSON/coach, list of PLAYERGAMESTATS), list of PERSON/officials), list of PLAYERs, list of GAMEEVENTs(insert TEAMs, list of PLAYERs), GAMECONTENT) if (Convert.ToInt16(schedule.totalGames) > 0) { foreach (Game g in schedule.games) { i = GameData.InsertGame(g, scheduleID); //--------------------------------------------------- // Insert the Home and Away TEAMs into the DB // INCLUDES: Insert the VENUE, list of PERIODs, BOXSCOREs(insert the TEAMGAMESTATS(insert the PERSON/coach, list of PLAYERGAMESTATS), list of PERSON/officials), list of PLAYERs, list of GAMEEVENTs(insert TEAMs, list of PLAYERs), GAMECONTENT) // Insert the Coach (PERSON) for each team if (!(g.gameBoxScore.homeTeamStats.coach is null)) { i = PersonData.InsertPerson(g.gameBoxScore.homeTeamStats.coach); } if (!(g.gameBoxScore.awayTeamStats.coach is null)) { i = PersonData.InsertPerson(g.gameBoxScore.awayTeamStats.coach); } // Insert the game VENUE if (!(g.gameVenue is null)) { i = VenueData.InsertVenue(g.gameVenue); } // Insert the game Officials (PERSON) if (!(g.gameBoxScore.officials is null)) { foreach (Person p in g.gameBoxScore.officials) { i = PersonData.InsertPerson(p); // Insert officials list to the cross reference table (tblGameOfficials) i = PersonData.InsertGameOfficials(g.gameID, p.personId); } } // Insert the Home Team: i = TeamData.InsertTeam(g.homeTeam); i = TeamData.InsertTeam(g.awayTeam); // Insert the CONFERENCE of each team: i = ConferenceData.InsertConference(g.homeTeam.teamConference); i = ConferenceData.InsertConference(g.awayTeam.teamConference); //Insert the DIVISION of each team: if (!(g.homeTeam.teamDivision is null)) { i = DivisionData.InsertDivision(g.homeTeam.teamDivision); } if (!(g.awayTeam.teamDivision is null)) { i = DivisionData.InsertDivision(g.awayTeam.teamDivision); } //Insert the PERIODs of the Game if (!(g.periodData is null)) { foreach (Period p in g.periodData) { i = PeriodData.InsertPeriod(p); } } // Insert the details and stats for each home PLAYER if (!(g.gameBoxScore.homeTeamStats.teamPlayers is null)) { foreach (PlayerGameStats homepgs in g.gameBoxScore.homeTeamStats.teamPlayers) { i = PlayerData.InsertPlayer(homepgs); i = PlayerGameStatsData.InsertPlayerGameStats(homepgs, g.gameID); } } // Insert the details and stats for each away PLAYER if (!(g.gameBoxScore.awayTeamStats.teamPlayers is null)) { foreach (PlayerGameStats awaypgs in g.gameBoxScore.awayTeamStats.teamPlayers) { i = PlayerData.InsertPlayer(awaypgs); i = PlayerGameStatsData.InsertPlayerGameStats(awaypgs, g.gameID); } } // Insert the GAMEEVENTS for the game if (!(g.gameEvents is null)) { foreach (GameEvent ge in g.gameEvents) { i = GameEventData.InsertGameEvent(ge, g.gameID); } } //--------------------------------------------------- } } }