Beispiel #1
0
        public static void Init(EscolaDataContext ctx)
        {
            ctx.Database.EnsureCreated();
            if (!ctx.Escolas.Any())
            {
                ctx.Escolas.AddRange(
                    new List <Models.Escola> {
                    new Models.Escola {
                        Nome = "FanSoft Sistema de Ensino", DataFundacao = new DateTime(1979, 09, 12), Endereco = "Av. Paulista, 1500"
                    },
                    new Models.Escola {
                        Nome = "Escola Nacional Diretiva", DataFundacao = new DateTime(1999, 08, 21), Endereco = "Rua das Flores, 2199"
                    },
                    new Models.Escola {
                        Nome = "Ensino Modular", DataFundacao = new DateTime(2007, 01, 1), Endereco = "Av. Carioca, 231"
                    },
                }
                    );

                ctx.SaveChanges();
            }
        }
Beispiel #2
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, Data.EscolaDataContext ctx)
        {
            app.UseStaticFiles();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                Data.DbInitializer.Init(ctx);
                app.UseNodeModules(env.ContentRootPath);
            }

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }