Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var routeBuilder = new RouteBuilder(app);

            routeBuilder.MapRoute("TryDBConnection",
                                  async context =>
            {
                LayerContext db = new LayerContext();
                db.Admins.Add(new Admin());
                db.SaveChanges();
                await context.Response.WriteAsync("ok");
            }
                                  );
            app.UseRouter(routeBuilder.Build());
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemple #2
0
 public void Save()
 {
     db.SaveChanges();
 }