// 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, TokenAuthorizationOptions tokenAuthorizationOptions, IMobileSecondHandContextOptions contextOptions) { loggerFactory.AddDebug(); loggerFactory.AddNLog(); app.UseApplicationInsightsRequestTelemetry(); env.ConfigureNLog("nlog.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 try { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { serviceScope.ServiceProvider.GetService <MobileSecondHandContext>() .Database.Migrate(); } } catch { } } var dbCtx = new MobileSecondHandContext(contextOptions.DbContextOptions); var category = dbCtx.Category.FirstOrDefault(); if (category == null) { CreateCategories(dbCtx); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.Use(next => async ctx => { try { await next(ctx); } catch (Exception exc) { if (ctx.Response.HasStarted) { throw exc; } ctx.Response.StatusCode = 401; } }); app.UseJwtBearerAuthentication(GetJwtBearerOptions(tokenAuthorizationOptions)); app.UseIdentity(); app.UseFacebookAuthentication(GetFacebookOptions(Configuration)); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseCors("myPolicy"); app.UseSignalR(); //app.UseWebSockets(); }
public ConversationDbService(IMobileSecondHandContextOptions mobileSecondHandContextOptions) { dbContextOptions = mobileSecondHandContextOptions.DbContextOptions; this.dbContext = new MobileSecondHandContext(mobileSecondHandContextOptions.DbContextOptions); }
public ConversationDbService(IMobileSecondHandContextOptions mobileSecondHandContextOptions) { this.dbContext = new MobileSecondHandContext(mobileSecondHandContextOptions.DbContextOptions); }