Example #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, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            // env.IsProduction();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed();
            }

            app.UseRouting();

            app.UseStaticFiles();

            app.CustomStaticFiles();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();

                endpoints.MapControllerRoute(
                    name: "products",
                    pattern: "products/{category?}",
                    defaults: new { controller = "Shop", action = "List" });
            });

            SeedIdentity.Seed(userManager, roleManager, Configuration).Wait();
        }
Example #2
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app">application instance</param>
        /// <param name="env">hosting environment instance</param>
        /// <param name="loggerFactory">for logging</param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseRouting();
            app.UseHttpsRedirection();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseDefaultFiles();

            //use swagger ui
            UseSwagger(app);

            app.UseSerilogRequestLogging();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);
        }
Example #3
0
        public void LoadSeed(SeedDatabase seedDb)
        {
            if (seedDb == null)
            {
                throw new ArgumentException("NCCH uses seed crypto, no seed database is loaded");
            }

            byte[] tid  = (BitConverter.IsLittleEndian) ? BitConverter.GetBytes(this.ProgramID) : BitConverter.GetBytes(this.ProgramID).FReverse();
            byte[] seed = new byte[16];

            try
            {
                seed = seedDb.Seeds[this.ProgramID];
            }
            catch (KeyNotFoundException)
            {
                throw new ArgumentException($"The specified seed database does not contain an entry for Title ID {tid.Hex()}.");
            }

            byte[] seedVerifyHash = Tools.HashSHA256(seed.MergeWith(tid));

            if (!Enumerable.SequenceEqual(seedVerifyHash.TakeItems(0x0, 0x4), this.SeedVerifyHashPart))
            {
                throw new ArgumentException($"The specified seed database contains an invalid seed for title id {tid.Hex()}");
            }

            this.SeededKeyY = Tools.HashSHA256(this.KeyY.MergeWith(seed)).TakeItems(0x0, 0x10);
        }
Example #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)
        {
            //SADECE GELİŞTİRME AŞAMASINDA ÇALIŞACAK BİR METHOD
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed();
            }
            app.UseStaticFiles();    //wwwroot u dışarıya açmak için
            app.CustomStaticFiles(); //node_modules 'ü dışarıya açmak için
            app.UseRouting();

            //BU KISIMDAKI ROUTING ESKI ROUTING KULLANIMI .net Core 2.2 vs.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "products",
                    template: "products/{category?}",
                    defaults: new { controller = "Shop", action = "List" }
                    );
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}"
                    );
            });

            // BU KISIMDAKİ ENDPOINT KULLANIMI YENI KULLANIM 3.1
            //// The equivalent of 'app.UseMvcWithDefaultRoute()'
            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapDefaultControllerRoute();
            //    // Which is the same as the template
            //    endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            //});
        }
Example #5
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();          // Create host app

            host = SeedDatabase.CreateDatabaseIfNotExists(host); // Seed if needed
            host.Run();                                          //Run
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed();
            }
            app.UseStaticFiles();
            app.CustomStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "adminProducts",
                    template: "admin/products",
                    defaults: new { controller = "Admin", action = "ProductList" }
                    );

                routes.MapRoute(
                    name: "adminProducts",
                    template: "admin/products/{id?}",
                    defaults: new { controller = "Admin", action = "EditProduct" }
                    );

                routes.MapRoute(
                    name: "products",
                    template: "products/{category?}",
                    defaults: new { controller = "Shop", action = "List" }
                    );

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}"
                    );
            });
        }
Example #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, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

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

            SeedDatabase.Initialize(app.ApplicationServices);
        }
Example #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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);
            //app.UseHttpsRedirection();

            app.UseRouting();

            app.UseStaticFiles();

            //app.UseSpaStaticFiles();

            //app.UseSpa(config =>
            //{
            //    config.Options.SourcePath = "ClientApp";
            //    if (env.IsDevelopment())
            //    {
            //        //config.UseAngularCliServer(nmpScript: "start");
            //    }
            //});

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #9
0
        public static async Task InitializeAsync(IServiceProvider services)
        {
            //var roleManager = services.GetRequiredService<RoleManager<IdentityRole>>();
            //await EnsureRolesAsync(roleManager);
            //var userManager = services.GetRequiredService<UserManager<ApplicationUser>>();
            //await EnsureTestAdminAsync(userManager);
            ILogger <Program>?logger = services.GetRequiredService <ILogger <Program> >();

            if (logger == null)
            {
                throw new ApplicationInitializationException("failed to get logger during initialization.");
            }
            IConfiguration?configuration = services.GetRequiredService <IConfiguration>();

            if (configuration == null)
            {
                throw new ApplicationInitializationException("failed to get configuration during initialization.");
            }
            ApplicationDbContext?dbContext = services.GetRequiredService <ApplicationDbContext>();

            if (dbContext == null)
            {
                throw new ApplicationInitializationException("failed to get dbContext during initialization.");
            }
            bool dbSeeded = await SeedDatabase.SeedAll(logger, configuration, dbContext);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CountryDbContext context)
        {
            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.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            SeedDatabase.SeedDb(context);
        }
Example #11
0
        public async static Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services      = scope.ServiceProvider;
                var loggerFactory = services.GetRequiredService <ILoggerFactory>();
                try
                {
                    var userManager = services.GetRequiredService <UserManager <ApplicationUser> >();
                    var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >();
                    var context     = services.GetRequiredService <LibraryContext>();
                    context.Database.Migrate();
                    await SeedDatabase.SeedEssentialsAsync(userManager, roleManager);
                }
                catch (Exception ex)
                {
                    var logger = loggerFactory.CreateLogger <Program>();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
Example #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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseMiddleware <ApiLoggingMiddleware>();

            app.UseCors(builder => builder
                        .WithOrigins("*")
                        .AllowAnyMethod()
                        .AllowCredentials()
                        .WithHeaders("Accept", "Content-Type", "Origin", "X-My-Header"));

            SeedDatabase.Initializer(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseAuthentication();

            app.UseHttpsRedirection();
            app.UseMvc();
        }
Example #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)
        {
            app.UseSwagger();
            app.UseAuthentication();

            if (env.IsDevelopment() || env.IsStaging())
            {
                app.UseSwaggerUI(options =>
                                 options.SwaggerEndpoint("/swagger/v1/swagger.json", "Gtd System v1")
                                 );

                SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);
            }


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseCors(MyAllowSpecificOrigins);
            //app.UseHttpsRedirection();
            app.UseMvc();
        }
Example #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseStaticFiles();
            if (env.IsDevelopment())
            {
                SeedDatabase.Seed();
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "productdetails",
                    pattern: "{url}",
                    defaults: new { controller = "Shop", action = "details" }
                    );

                endpoints.MapControllerRoute(
                    name: "products",
                    pattern: "products/{category?}",
                    defaults: new { controller = "Shop", action = "List" }
                    );

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}"
                    );
            });
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseStaticFiles();//wwwroot altındaki klasörler açılır
            app.UseStaticFiles(new StaticFileOptions {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), "node_modules")),
                RequestPath = "/modules"
            });
            if (env.IsDevelopment())
            {
                SeedDatabase.Seed();
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();


            app.UseEndpoints(endpoints =>//uygulamanın ana dizinine sahip istek geldiğinde bir response string ifade göndermek
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Product}/{action=Index}/{id?}"
                    //controller=home dedim yani sen birşey çağırmasan bile ilk olarak home çıkar karşına actionu ise ındex
                    );
            });
        }
Example #16
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.UseDeveloperExceptionPage();
            }

            app.UseCors(MyAllowSpecificOrigins);

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            using (var context = app.ApplicationServices.GetService <CarbonKitchenDbContext>())
            {
                context.Database.EnsureCreated();

                SeedDatabase.AddData(context);

                context.SaveChanges();
            }
        }
Example #17
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            var serviceProvider = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider;

            SeedDatabase.Initialize(serviceProvider);

            app.UseAuthentication();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseCors("CorsPolicy");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHub <ChatHub>("/chatHub");
            });
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                ConfigureUseSwagger(app, env); // Do not expose Swagger interface in production
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseAuthentication();

            IServiceProvider serviceProvider = app.ApplicationServices
                                               .GetRequiredService <IServiceScopeFactory>()
                                               .CreateScope()
                                               .ServiceProvider;

            SeedDatabase.Initialize(serviceProvider);

            app.UseMvc();
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "areas",
            //        template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
            //    );
            //});
        }
Example #19
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();          //create our host app

            host = SeedDatabase.CreateDatabaseIfNotExists(host); // seed if needed
            host.Run();                                          // run our app/webserver
        }
Example #20
0
        public NCSD(FileStream ncsdStream, CryptoEngine ce = null, SeedDatabase seedDb = null)
        {
            Load(ncsdStream);

            this.Cryptor      = ce;
            this.SeedDatabase = seedDb;
        }
Example #21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataContext dataContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed(dataContext); //seed database bu sekilde tanimlanmis oldu
                                                //Hata  olustugunda da hata kodlarını gostersin
                app.UseDeveloperExceptionPage();

                //Server tarafindan gonderilen hata kodlarını gormek icin
                app.UseStatusCodePages();

                //Varsayilan olarak wwwroot klasorunu aktif hale getiriyoruz.
                app.UseStaticFiles();

                app.UseAuthentication();  //2. db icin eklendi buda

                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine
                                                                (Directory.GetCurrentDirectory(), @"node_modules")),
                    RequestPath = new PathString("/vendor")
                });


                //app.Run(async (context) =>
                //{
                //    await context.Response.WriteAsync("Hello World!");
                //});
                app.UseMvcWithDefaultRoute();
            }
        }
Example #22
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            //بدل ما اشيل implementations كتير
            //وارمي فيه كل حاجه مش محتاج
            //الترتيب هنا مهم عشان الpipline
            //ask hani fro course of migration .net core
            //.net standards because of framworks



            //  app.UseHttpsRedirection();
            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseAuthentication();

            app.UseMvc();

            //me7tageen n2o
            //m el database
            //lifetimw scope and ioc
        }
Example #23
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("AllowOrigin");

            app.UseRouting();

            app.UseAuthorization();

            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseSwagger();

            if (env.IsDevelopment())
            {
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "UI API"));
            }
            else
            {
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/api/swagger/v1/swagger.json", "UI API"));
            }

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #24
0
        // This method gets called by the runtime. Use this method to configure the http request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerManager logger)
        {
            app.UseCors("MyPolicy");

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                //app.UseRewriter(new RewriteOptions().AddRedirectTohttp(StatusCodes.Status301MovedPermanently, 443));
                app.UseExceptionHandler("/Home/Error");
            }


            bool recreateDB = Configuration.GetValue <bool>("AppSettings:ReCreateDB");

            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider, recreateDB);
            app.UseAuthentication();

            //app.UseMvc();
            app.UseSession();
            app.UseStaticFiles();
            var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >();

            app.UseRequestLocalization(options.Value);
            app.ConfigureExceptionHandler(logger);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #25
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.CustomStaticFiles();
            app.UseAuthentication();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "products",
                    template: "products/{category?}",
                    defaults: new { controller = "Shop", action = "List" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #26
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())
            {
                SeedDatabase.Seed();
                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.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CourseContext Ccontext, UserContext userContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed(Ccontext);
                SeedDatabase.Seed(userContext);
                app.UseMvc(routes =>
                {
                    routes.MapRoute("myroute", "{controller=Course}/{action=Index}/{id?}");
                });
            }

            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();

            //If I decide to use npm as package manager this is the approach to use.
            //app.UseStaticFiles(new StaticFileOptions()
            //{
            //    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"node_modules")),
            //    RequestPath = new PathString("/vendor")

            //});

            //contoller/action/id?
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute("myroute", "{controller=Course}/{action=Index}/{id?}");
            //});
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseStaticFiles();//wwwroot altındaki klasörler açılır
            app.UseStaticFiles(new StaticFileOptions {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), "node_modules")),
                RequestPath = "/modules"
            });
            if (env.IsDevelopment())
            {
                SeedDatabase.Seed();
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "products",
                    pattern: "products/{category?}",//Güncelledim. Kullanıcı category değeri verirse o kategori bilgileri gelsin--pattern:"products kullanıcı productsu çağırırsa
                    defaults: new { Controller = "Book", action = "list" }//bura gelsin
                    );

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Product}/{action=Index}/{id?}"
                    //controller=home dedim yani sen birşey çağırmasan bile ilk olarak home çıkar karşına actionu ise ındex
                    );
            });
        }
Example #29
0
        public NCCH(MemoryMappedFile ncch, long dataStart, CryptoEngine ce = null, SeedDatabase seedDb = null)
        {
            this.DataStart            = dataStart;
            this.NCCHMemoryMappedFile = ncch;

            Load(ce, seedDb);
        }
Example #30
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDatabase.Seed();
            }

            app.UseRouting();
            app.UseStaticFiles();
            app.CustomStaticFiles();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(name: "adminSliders", "admin/slider", defaults: new { controller = "Slider", action = "SliderList" });
                endpoints.MapControllerRoute(name: "adminSliders", "admin/slider/{id?}", defaults: new { controller = "Slider", action = "EditSlider" });
                endpoints.MapControllerRoute(name: "adminProducts", "admin/products", defaults: new { controller = "Product", action = "ProductList" });
                endpoints.MapControllerRoute(name: "adminProducts", "admin/products/{id?}", defaults: new { controller = "Product", action = "EditProduct" });
                endpoints.MapControllerRoute(name: "products", "products/{category?}", defaults: new { controller = "Shop", action = "Index" });
                endpoints.MapControllerRoute(name: "news", "news", defaults: new { controller = "News", action = "Index" });
                endpoints.MapControllerRoute(name: "admin", "admin/index", defaults: new { controller = "Admin", action = "Index" });
                endpoints.MapControllerRoute(name: "default", "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(name: "cart", "cart", defaults: new { controller = "Cart", action = "Index" });
            });

            SeedIdentity.Seed(userManager, roleManager, Configuration).Wait();
        }