public static void InitialLoad(IServiceProvider serviceProvider) { using (var context = new RallyDbContext(serviceProvider.GetRequiredService <DbContextOptions <RallyDbContext> >())) { var season = new Season(); season.Id = 1; season.Name = "Season 2021"; //season.BeginningDate = DateTime.Now.AddDays(20); season.BeginningDate = DateTime.Now; var team = new Team { Id = 1, Name = "Blue", IdCode = "AZL" }; var pilotCarlos = new Pilot(); pilotCarlos.Id = 1; pilotCarlos.Name = "Carlos"; team.AddPilot(pilotCarlos); season.AddTeam(team); context.Seasons.Add(season); context.SaveChanges(); } }
public void Initialize() { season = new Season(); season.Id = 1; season.Name = "Season 2021"; team1 = new Team(); team1.Id = 1; team1.Name = "TeamTest1"; team2 = new Team(); team2.Id = 2; team2.Name = "TeamTest2"; team3 = null; season.AddTeam(team1); season.AddTeam(team2); season.AddTeam(team3); }
public void GivenANewSeasonWithTheseTeamsAndPlayers(string seasonName, Table table) { var season = new Season(seasonName); var league = new League(); league.AddSeason(season); var teams = new List <Team>(); foreach (var tableRow in table.Rows) { var teamName = tableRow[0]; var team = season.Teams.FirstOrDefault(x => x.Name == teamName) ?? season.AddTeam(new Team(teamName)); var playerName = tableRow[1]; var player = team.Players.FirstOrDefault(x => x.Name == playerName) ?? team.AddPlayer(new Player(playerName)); } season.SetInContext(); league.SetInContext(); }