Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews().AddRazorRuntimeCompilation();
            services.AddSession();
            services
            .AddSingleton(Configuration)
            .AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            //*=== SETTING CONNECTION STRING ===*//
            string dbConn = "";

            if (HostEnvironment.IsDevelopment())
            {
                dbConn = Configuration.GetConnectionString("EKanbanWebDBConnection");
            }
            if (HostEnvironment.IsProduction())
            {
                DbConf db = new DbConf(Configuration, HostEnvironment);
                dbConn = db.GetConnectionString();
            }
            services.AddDbContext <EKanbanWebDBContext>(options =>
                                                        options.UseSqlServer(dbConn,
                                                                             sqlServerOptionsAction: sqlOptions =>
            {
                sqlOptions.EnableRetryOnFailure();
            }));
            //=========================================

            services.Configure <IISServerOptions>(options =>
            {
                options.AutomaticAuthentication = false;
            });
        }
Beispiel #2
0
 public SqlHelper(IConfiguration Configuration, IHostEnvironment hostEnvironment)
 {
     Conf = Configuration;
     _db  = new DbConf(Conf, hostEnvironment);
 }