예제 #1
0
        private static void SeedDatabase(IHost host)
        {
            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;
            var context  = services.GetRequiredService <UsersWebApiContext>();

            UsersContextSeed.SeedAsync(context);
        }
예제 #2
0
        public void PrepareDatabase(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            try
            {
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    var settings = scope.ServiceProvider.GetRequiredService <IOptions <UserSettings> >();

                    var context          = new MongoContext(settings);
                    var usersContextSeed = new UsersContextSeed(context);
                    usersContextSeed.SeedAsync(app, loggerFactory).Wait();
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
예제 #3
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.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

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

            UsersContextSeed.SeedAsync(app).Wait();
        }
예제 #4
0
파일: Startup.cs 프로젝트: opage/sfeirpuppy
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseCors("CorsPolicy");
            app.UseMvcWithDefaultRoute();
            app.UseSwagger()
            .UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sfeir puppy API V1");
                c.OAuthClientId("usersswaggerui");
                c.OAuthAppName("Users Swagger UI");
            });

            // Seed Data
            UsersContextSeed.SeedAsync(app, loggerFactory).Wait();
        }