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

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

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

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Gateway API V1");

                // To serve SwaggerUI at application's root page, set the RoutePrefix property to an empty string.
                c.RoutePrefix = string.Empty;
            });

            // Wait for db to be ready (Docker compose)
            Thread.Sleep(5000);
            while (1 == 1)
            {
                try
                {
                    //Creates DB and tables if not exists.
                    var connectionString = Configuration.GetConnectionString("PaymentConnectionString");
                    Console.WriteLine("Connecting to db: " + connectionString);
                    DbInitilization.EnsureDatabase(connectionString);
                    Console.WriteLine("Connected to db.");
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine("DB connection error: " + e);
                    Thread.Sleep(1000);
                }
            }
        }
Exemple #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, UserManager <User> userManager, DbContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "UserCase v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            dbContext.Database.Migrate();
            DbInitilization.SeedUsers(userManager).Wait();
        }