Ejemplo n.º 1
0
        public static void Initialize(FormulaOneDbContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            //already initialized
            if (!context.Teams.Any())
            {
                var teams = new Team[]
                {
                    new Team {
                        Name = "Scuderia Ferrari", YearOfFoundation = 1929, AttainedWorldChampionships = 15, PaidEntryFee = true
                    },
                    new Team {
                        Name = "Red Bull Racing", YearOfFoundation = 2004, AttainedWorldChampionships = 4, PaidEntryFee = true
                    },
                    new Team {
                        Name = "Mercedes-AMG Petronas", YearOfFoundation = 2010, AttainedWorldChampionships = 8, PaidEntryFee = true
                    },
                    new Team {
                        Name = "McLaren", YearOfFoundation = 1963, AttainedWorldChampionships = 12, PaidEntryFee = true
                    }
                };

                foreach (Team t in teams)
                {
                    context.Teams.Add(t);
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public DriversController(FormulaOneDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Ejemplo n.º 3
0
 public TeamRepository(FormulaOneDbContext DbContext)
 {
     db = DbContext;
 }