public static Task SeedTestDataAsync(this MandarinDbContext mandarinDbContext)
 {
     using var connection = mandarinDbContext.GetConnection();
     connection.Open();
     mandarinDbContext.RunMigrations();
     return(Task.CompletedTask);
 }
Exemple #2
0
        /// <summary>
        /// Configures the HTTP Pipeline for Mandarin.
        ///
        /// <remarks>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </remarks>
        /// </summary>
        /// <param name="app">The application to be configured.</param>
        /// <param name="env">The application host environment.</param>
        /// <param name="mandarinDbContext">The application database context.</param>
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MandarinDbContext mandarinDbContext)
        {
            mandarinDbContext.RunMigrations();

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

            app.SafeUseAllElasticApm(this.configuration);
            app.UseSerilogRequestLogging();
            app.UseHttpsRedirection();
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();

            app.AddLegacyRedirect("/static/logo-300.png", "/static/images/logo.png");
            app.AddLegacyRedirect("/static/Century-Schoolbook-Std-Regular.otf", "/static/fonts/Century-Schoolbook-Std-Regular.otf");

            app.UseRouting();

            app.UseGrpcWeb(new GrpcWebOptions {
                DefaultEnabled = true
            });
            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGrpcService <CommissionsGrpcService>();
                endpoints.MapGrpcService <EmailGrpcService>();
                endpoints.MapGrpcService <FixedCommissionsGrpcService>();
                endpoints.MapGrpcService <ProductsGrpcService>();
                endpoints.MapGrpcService <StockistsGrpcService>();
                endpoints.MapFallbackToFile("index.html");
            });
        }