// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, VraagContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); DbInitializer.Initialize(context); }
public static void Initialize(VraagContext context) { context.Database.EnsureCreated(); // Look for any countries. if (context.Leerkachten.Any()) { return; // DB has been seeded } context.Leerkachten.AddRange( new Leerkracht { Naam = "Peeters", Voornaam = "Tom" }, new Leerkracht { Naam = "Marien", Voornaam = "Sven" } ); context.SaveChanges(); context.Studenten.AddRange( new Student { Naam = "Tauil", Voornaam = "Nabil" }, new Student { Naam = "Creve", Voornaam = "Koen" }, new Student { Naam = "Meysman", Voornaam = "Scott" } ); context.SaveChanges(); context.Vragen.AddRange( new Vraag { Titel = "Wat is een database", Tekst = "", Score = 5, Datum = DateTime.Parse("2017-12-12"), Markeren = false, }, new Vraag { Titel = "Waarom is 42 het antwoord op alles", Tekst = "Hitchikers Guide To The Galaxy", Score = 42, Datum = DateTime.Parse("2017-06-12"), Markeren = true, }, new Vraag { Titel = "Geen vraag enkel test", Tekst = "Groot", Score = -5, Datum = DateTime.Parse("055-06-26"), Markeren = false, } ); context.SaveChanges(); }