Ejemplo n.º 1
0
        private static ISessionFactory BuildTestSessionFactory()
        {
            var testDatabaseConnectionString = "LocalDB";
            var config = DatabaseConfiguration.Configure(testDatabaseConnectionString);

            /*
             * Need to comment these out when not needed because session factory can only be created once.
             * Database schemas need to be created BEFORE NHibernate schema export.
             * This needs to be run only once.
             */
            /*
             * var fac = DatabaseConfiguration.BuildSessionFactory(config);
             *
             * CreateSchemas(fac);*/

            // Drop old database if any, create new schema
            config.ExposeConfiguration(cfg => {
                var export = new SchemaExport(cfg);
                //export.SetOutputFile(@"C:\Temp\vdb.sql");
                export.Drop(false, true);
                export.Create(false, true);
            });

            var fac = DatabaseConfiguration.BuildSessionFactory(config);

            FinishDatabaseConfig(fac);

            return(fac);
        }
Ejemplo n.º 2
0
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext dataContext)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        // Hangfire
        HangfireConfiguration.Configure(app);

        app.UseLiveReload();

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints => endpoints.MapRazorPages());

        DatabaseConfiguration.Configure(dataContext);
    }
Ejemplo n.º 3
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     DatabaseConfiguration.Configure(app);
     LoggingConfiguration.Configure(app, _configuration, loggerFactory);
     RewriteConfiguration.Configure(app, env);
     SimpleInjectorConfiguration.Configure(app);
     CorsConfiguration.Configure(app, _configuration);
     MvcConfiguration.Configure(app, env);
     SwaggerConfiguration.Configure(app);
     AutoMapperConfiguration.Configure();
     FluentValidationConfiguration.Configure();
     HangfireConfiguration.Configure(app, _configuration);
 }
Ejemplo n.º 4
0
        public Startup(IWebHostEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile($"{AppSettingsFile}.{JsonTermination}", false, true)
                          .AddJsonFile($"{AppSettingsFile}.{env.EnvironmentName}.{JsonTermination}", false, true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            DatabaseConfiguration.Configure();
            AppSettings.Configure(Configuration);
            IoCConfiguration.ConfigureServiceLocator();
        }
Ejemplo n.º 5
0
        public ISessionFactory BuildTestSessionFactory()
        {
            var testDatabaseConnectionString = "LocalDB";
            var config = DatabaseConfiguration.Configure(testDatabaseConnectionString);

            // Database schemas need to be created BEFORE NHibernate schema export.
            CreateSchemas(testDatabaseConnectionString);

            config.ExposeConfiguration(cfg => RecreateSchema(cfg, testDatabaseConnectionString));

            var fac = DatabaseConfiguration.BuildSessionFactory(config);

            return(fac);
        }
Ejemplo n.º 6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddControllersWithViews(config =>
            {
                var policy = new AuthorizationPolicyBuilder()
                             .RequireAuthenticatedUser()
                             .Build();
                config.Filters.Add(new AuthorizeFilter(policy));
            });

            services.AddHsts(options =>
            {
                options.Preload           = true;
                options.IncludeSubDomains = true;
                options.MaxAge            = TimeSpan.FromDays(365);
            });

            services.AddHttpsRedirection(options =>
            {
                options.RedirectStatusCode = StatusCodes.Status308PermanentRedirect;
                options.HttpsPort          = _configuration.GetValue <int>("HttpsPort");
            });

            services.AddApplicationInsightsTelemetry();

            var authenticationConfig = new AuthenticationConfiguration(services, _configuration, _environment);

            authenticationConfig.Configure();

            var databaseConfig = new DatabaseConfiguration(services, _configuration, _environment);

            databaseConfig.Configure();

            var dataAccessConfiguration = new DataAccessConfiguration(services, _configuration, _environment);

            dataAccessConfiguration.Configure();

            var businessLogicConfiguration = new BusinessLogicConfiguration(services, _configuration, _environment);

            businessLogicConfiguration.Configure();
        }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DavidMorales.WebHost v1"));

                app.UseDeveloperExceptionPage();

                app.UseCors(builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            }
            else
            {
                //app.UseExceptionHandler("/Error");
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DavidMorales.WebHost v1"));
                app.UseDeveloperExceptionPage();

                app.UseCors(builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            }

            RestServiceConfiguration.Configure(app);
            DatabaseConfiguration.Configure(app);
            IdentityServiceConfiguration.Configure(app);
            AuthenticationConfiguration.Configure(app);
            AppAuthorizationConfiguration.Configure(app);
        }