Ejemplo n.º 1
0
        private void SeedTeams(WinnersLeagueContext dbContext)
        {
            var json = File.ReadAllText(JSON_FILE);

            var deserializer = JsonConvert.DeserializeObject <Team[]>(json);

            dbContext.Teams.AddRange(deserializer);
            dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        private void SeedStadiums(WinnersLeagueContext dbContext)
        {
            var json = File.ReadAllText(JSON_FILE);

            var stadiums = JsonConvert.DeserializeObject <Stadium[]>(json);

            dbContext.AddRange(stadiums);
            dbContext.SaveChanges();
        }
Ejemplo n.º 3
0
        private void SeedLeagues(WinnersLeagueContext dbContext)
        {
            var teams = dbContext.Teams.ToArray();

            var league = new League
            {
                Name         = "Primier League",
                Country      = "England",
                CountOfTeams = teams.Count(),
                Teams        = teams,
            };

            dbContext.Leagues.Add(league);
            dbContext.SaveChanges();
        }