Пример #1
0
 public HomeController(GeoDatabaseContext dbContext)
 {
     _databaseContext = dbContext;
 }
Пример #2
0
 public Repository(GeoDatabaseContext context)
 {
     DbContext = context;
 }
Пример #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, GeoDatabaseContext dbContext)
        {
            env.ConfigureNLog("nlog.config");
            loggerFactory.AddNLog();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
                app.UseExceptionHandler(appBuilder =>
                {
                    // Глобальный обработчик ошибок. Логирование ошибки и возврат сообщения с кодом 500.
                    appBuilder.Run(async context =>
                    {
                        IExceptionHandlerFeature exceptionHandlerFeature = context.Features.Get <IExceptionHandlerFeature>();
                        if (exceptionHandlerFeature != null)
                        {
                            ILogger logger = loggerFactory.CreateLogger("Global exception logger");
                            logger.LogError(500, exceptionHandlerFeature.Error, exceptionHandlerFeature.Error.Message);
                        }

                        context.Response.StatusCode = 500;
                        await context.Response.WriteAsync("An unexpected fault happened. Try again later.");
                    });
                });
            }

            app.UseHttpsRedirection();

            app.UseStaticFiles();
            dbContext.Load();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Пример #4
0
 public RangeRepository(GeoDatabaseContext databaseContext) : base(databaseContext)
 {
 }
Пример #5
0
 public LocationRepository(GeoDatabaseContext databaseContext) : base(databaseContext)
 {
 }