Example #1
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)
        {
            if (env.IsDevelopment())
            {
                using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    // Insert data in database
                    DataSeeder.InitializeDepartments(scope.ServiceProvider);
                    DataSeeder.InitializeUsers(scope.ServiceProvider);
                    DataSeeder.InitializeMedicine(scope.ServiceProvider);

                    #region Not validated seed
                    //DataSeeder.InitializeExternalDrugstoreMedicines(scope.ServiceProvider);
                    //DataSeeder.InitializeExternalDrugstoreSoldMedicines(scope.ServiceProvider);
                    //DataSeeder.InitializePresciptions(scope.ServiceProvider);
                    #endregion
                }
            }

            loggerFactory.AddFile("Logs/drugstore-{Date}.txt", LogLevel.Warning);
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    "default",
                    "{controller}/{action}",
                    new { controller = "Account", action = "Redirect" }
                    );
            });
        }