Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDBInitializer dbInit)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();

            app.UseRouting();
            dbInit.Initialize();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{area=Customer}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
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, IHostingEnvironment env, IDBInitializer dBInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseCookiePolicy();
            dBInitializer.Initialize();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 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, IDBInitializer dBInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseCookiePolicy();
            dBInitializer.Initialize();

            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    "ByYearMonth",
                //    "make/bikes/{year:int:length(4)}/{month:int:range(1,12)}",
                //    new {controller = "make", action="ByYearMoth"}
                //    );

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Bike}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDBInitializer dBInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Bike/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseCookiePolicy();
            dBInitializer.Initialize();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Bike}/{action=Index}/{id?}"
                    );
            });
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDBInitializer dBInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            //app.UseAuthentication();
            app.UseIdentityServer();

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

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


            dBInitializer.Initialize().Wait();
        }
Ejemplo n.º 6
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
					NekoPetShopContext context = scope.ServiceProvider.GetService<NekoPetShopContext>();
					IDBInitializer dbInitializer = scope.ServiceProvider.GetService<IDBInitializer>();
					dbInitializer.Seed(context);
                }
                app.UseDeveloperExceptionPage();
            }
            else
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
					NekoPetShopContext context = scope.ServiceProvider.GetService<NekoPetShopContext>();
					IDBInitializer dbInitializer = scope.ServiceProvider.GetService<IDBInitializer>();
					dbInitializer.Seed(context);
				}
                app.UseDeveloperExceptionPage();
                app.UseHsts();
            }

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

			app.UseHttpsRedirection();
			app.UseAuthentication();
			app.UseMvc();
        }
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, IHostingEnvironment env, IDBInitializer dbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

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

            app.UseAuthentication();

            dbInitializer.Initialize();
            app.UseAuthentication();

            app.UseSession();



            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area=Login}/{controller=Login}/{action=Login}"
                    );
            });
        }
Ejemplo n.º 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDBInitializer dbInitialize)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                //app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }

            CultureInfo newCulture = new CultureInfo("pl-PL");

            newCulture.NumberFormat.NumberDecimalSeparator = ".";
            newCulture.NumberFormat.NumberGroupSeparator   = " ";
            newCulture.DateTimeFormat.ShortDatePattern     = "dd-MM-yyyy";
            newCulture.DateTimeFormat.ShortTimePattern     = "HH:mm:ss";
            newCulture.DateTimeFormat.FullDateTimePattern  = "dd-MM-yyyy HH:mm:ss";
            newCulture.DateTimeFormat.DateSeparator        = "-";
            newCulture.DateTimeFormat.TimeSeparator        = ":";

            CultureInfo.DefaultThreadCurrentCulture   = newCulture;
            CultureInfo.DefaultThreadCurrentUICulture = newCulture;
            CultureInfo.CurrentCulture   = newCulture;
            CultureInfo.CurrentUICulture = newCulture;

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(newCulture),
                SupportedCultures     = new List <CultureInfo>
                {
                    newCulture,
                },
                SupportedUICultures = new List <CultureInfo>
                {
                    newCulture,
                }
            });

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

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Account}/{action=LogIn}/{id?}");
                endpoints.MapRazorPages();
            });

            dbInitialize.Initializer();
        }
Ejemplo n.º 9
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())
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    PetShop2020DBContext context = scope.ServiceProvider.GetService <PetShop2020DBContext>();
                    context.Database.EnsureDeleted(); // only in dev mode. never in prod mode or the whole database will be lost.
                    context.Database.EnsureCreated();
                    IDBInitializer DbInit = scope.ServiceProvider.GetService <IDBInitializer>();
                    DbInit.Seed(context);
                }

                app.UseDeveloperExceptionPage();
            }
            if (env.IsProduction())
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    PetShop2020DBContext context = scope.ServiceProvider.GetService <PetShop2020DBContext>();
                    context.Database.EnsureCreated();
                    IDBInitializer dbInitializer = scope.ServiceProvider.GetService <IDBInitializer>();
                    dbInitializer.Seed(context);
                }
            }
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "Pet Shop API");
                options.RoutePrefix = "";
            });

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>

                             { endpoints.MapControllers(); });
        }
Ejemplo n.º 10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDBInitializer dbInit)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            dbInit.InitializeAsync();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Ejemplo n.º 11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDBInitializer dbInit)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();
            app.UseCookiePolicy();

            app.UseRouting();

            // Vai inicializar o banco, se não existir roles ou o usuário Admin padrão.
            dbInit.Initialize();

            app.UseAuthentication();
            app.UseAuthorization();
            //app.UseMvc();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{area=Customer}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //      name: "areas",
            //      template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
            //    );
            //});
        }
Ejemplo n.º 12
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,
                              IDBInitializer initializer,
                              IAuthConfiguration authConfig)
        {
            loggerFactory.AddConsole(configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCorsConfig(env)
            .UseIdentity()
            .UseJwtBearerTokenAuthentication(authConfig)
            .UseMiddleware <ExceptionHandlingMiddleware>()
            .UseSignalR2()
            .UseMvc()
            .UseSwagger()
            .UseSwaggerUI(s => s.SwaggerEndpoint("/swagger/v1/swagger.json", "WordHunt WebAPI"));

            initializer.InitDatabase().Wait();
        }
Ejemplo n.º 13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDBInitializer dbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/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();
            }

            //create DB on startup
            using (var db = new RepositoryContext())
            {
                db.Database.EnsureCreated();
            }
            dbInitializer.Initialize();
            SettingsHandler.Settings.ReadSettings();
            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UseSignalR(routes =>
            {
                routes.MapHub <QueueHub>("/queueHub");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area=Patient}/{controller=Home}/{action=Index}/{id?}");
            });
        }
 public ForumThreadRepository(IDBInitializer dbInitializer)
 {
     this.dbInitializer = dbInitializer;
 }
Ejemplo n.º 15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              IDBInitializer dbInitializer,
                              IAntiforgery antiforgery
                              )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseMiddleware <LoggingExceptionHandler>();
                //The default HSTS value is 30 days.You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            var swaggerOptions = new WebApp.Utility.SwaggerOptions();

            Configuration.GetSection(nameof(WebApp.Utility.SwaggerOptions)).Bind(swaggerOptions);

            app.UseSwagger();

            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", swaggerOptions.Description);
            });
            //create DB on startup
            EnsureDbCreated();

            dbInitializer.Initialize();
            SettingsHandler.Settings.ReadSettings();
            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            var corsSettings = new CorsSettings();

            Configuration.GetSection(nameof(CorsSettings)).Bind(corsSettings);

            app.UseCors(builder =>
            {
                builder
                .WithOrigins(corsSettings.AllowedOrigins)
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials();
            });

            app.UseAuthentication();
            app.UseSignalR(routes =>
            {
                routes.MapHub <QueueHub>("/queueHub");
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area=Patient}/{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 16
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, LunchVoteContext context, IDBInitializer dbInitializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            Mapper.Initialize(cfg => cfg.AddProfiles(typeof(Program).Assembly.GetName().Name));

            context.Database.EnsureCreated();
            dbInitializer.Initialize();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "LunchVote API V1");
                c.RoutePrefix = string.Empty;
            });

            app.UseCors(
                options => options.WithOrigins("https://localhost:44313", "http://localhost:4200").AllowAnyMethod().AllowAnyHeader()
                );

            app.UseMvc();
        }
Ejemplo n.º 17
0
 public ChatRepository(IDBInitializer dbInitializer)
 {
     this.dbInitializer = dbInitializer;
 }
Ejemplo n.º 18
0
 public DBInitiateCommand(ILogger logger, IDBInitializer dBInitializer)
 {
     this.logger        = logger;
     this.dBInitializer = dBInitializer;
 }
Ejemplo n.º 19
0
 public UserRepository(IDBInitializer dBInitializer)
 {
     dbInitializer = dBInitializer;
 }