// Constructor public IndexModel(AskDbContext dc, IOptionsSnapshot <AppConfiguration> optionsSnapshot) { this._dc = dc; this._cfg = optionsSnapshot.Value; this._dataSource = this._dc.Questions .Include(x => x.Category) .Where(x => x.DateAnswered.HasValue) .OrderByDescending(x => x.DateAnswered); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, AskDbContext context, UserManager <ApplicationUser> userManager, IMapper autoMapper) { autoMapper.ConfigurationProvider.AssertConfigurationIsValid(); // Show detailed errors in development environment if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } // Migrate database to last version //context.Database.Migrate(); // Seed initial data if in development environment if (env.IsDevelopment()) { // Create categories context.Seed(); // Create default user if (!userManager.Users.Any()) { var adminUser = new ApplicationUser { UserName = "******" }; var r = userManager.CreateAsync(adminUser, "pass.word123").Result; if (r != IdentityResult.Success) { var errors = string.Join(", ", r.Errors.Select(x => x.Description)); throw new Exception("Seeding default user failed: " + errors); } } } // HTTP error handling app.UseStatusCodePagesWithReExecute("/Error/{0}"); // Enable static file caching for one year app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => { ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=31536000"); } }); // Use other middleware app.UseAuthentication(); app.UseMvc(); }
public void Instance_Is_IdentityDbContext_Of_ApplicationUser_Comma_ApplicationRole_Comma_Integer() { //Arrange var type = typeof(IdentityDbContext <ApplicationUser, ApplicationRole, int>); var options = new DbContextOptionsBuilder <AskDbContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; //Act var context = new AskDbContext(options); //Assert Assert.IsInstanceOf(type, context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AskDbContext context, UserManager <ApplicationUser> userManager) { // Migrate database to last version context.Database.Migrate(); context.Seed(); // DEMO PURPOSES, REMOVE AS NEEDED // Seed initial data if in development environment if (env.IsDevelopment()) { // Create categories context.Seed(); // Create default user if (!userManager.Users.Any()) { var adminUser = new ApplicationUser { UserName = "******" }; var r = userManager.CreateAsync(adminUser, "pass.word123").Result; if (r != IdentityResult.Success) { var errors = string.Join(", ", r.Errors.Select(x => x.Description)); throw new Exception("Seeding default user failed: " + errors); } } } app.UseResponseCompression(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AskDbContext context) { // Migrate database to last version context.Database.Migrate(); context.Seed(); // DEMO PURPOSES, REMOVE AS NEEDED // Seed initial data if in development environment if (env.IsDevelopment()) { // Create categories context.Seed(); //// Create default user //if (!userManager.Users.Any()) //{ // var adminUser = new ApplicationUser { UserName = "******" }; // var r = userManager.CreateAsync(adminUser, "pass.word123").Result; // if (r != IdentityResult.Success) // { // var errors = string.Join(", ", r.Errors.Select(x => x.Description)); // throw new Exception("Seeding default user failed: " + errors); // } //} } app.UseResponseCompression(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBlazorDebugging(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); app.UseBlazor <Client.Startup>(); }
public IndexViewModel(IHostingEnvironment env, AskDbContext dbContext) : base(env) { this.dbContext = dbContext; }
public SyndicationController(AskDbContext dc, HtmlEncoder encoder) { this._dc = dc; this._encoder = encoder; }
public PagedUnansweredQuestionsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context) { }
public AwesomeQueryHandler(IProjector projector, AskDbContext context) : base(projector, context) { }
public CategoryController(AskDbContext askDbContext) { this.askDbContext = askDbContext; }
public SyndicationQuestionsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context) { }
// Constructor public IndexModel(AskDbContext dc) { this._dc = dc; }
public UpdateQuestionCommandHandler(AskDbContext context) : base(context) { }
// Constructor public HomeController(AskDbContext dc, IOptionsSnapshot <AppConfiguration> optionsSnapshot) { this._dc = dc; this._cfg = optionsSnapshot.Value; }
public QuestionsController(AskDbContext askDbContext, IOptionsSnapshot <AppConfiguration> optionsSnapshot) { this.askDbContext = askDbContext; this.appConfiguration = optionsSnapshot.Value; }
// Constructor public AdminController(AskDbContext dc, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager) { this._dc = dc; this._userManager = userManager; this._signInManager = signInManager; }
// Constructor public IndexModel(AskDbContext dc, IOptionsSnapshot <AppConfiguration> optionsSnapshot) { this._dc = dc; this._cfg = optionsSnapshot.Value; }
public QuestionsViewModel(IHostingEnvironment env, IOptionsSnapshot <AppConfiguration> config, AskDbContext dbContext) : base(env, config) { this.dbContext = dbContext; }
public CategoriesListItemsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context) { }
// Constructor public QuestionModel(AskDbContext dc) { this._dc = dc; }
public IndexViewModel(IHostingEnvironment env, AskDbContext dbContext, IQuestions questions) : base(env) { Data.PagingOptions.PageSize = 10; _questions = questions; }