示例#1
0
        // 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);
        }
示例#2
0
        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();
        }
示例#3
0
        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);
        }
示例#4
0
        // 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");
            });
        }
示例#5
0
        // 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>();
        }
示例#6
0
 public IndexViewModel(IHostingEnvironment env, AskDbContext dbContext) : base(env)
 {
     this.dbContext = dbContext;
 }
示例#7
0
 public SyndicationController(AskDbContext dc, HtmlEncoder encoder)
 {
     this._dc      = dc;
     this._encoder = encoder;
 }
 public PagedUnansweredQuestionsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context)
 {
 }
示例#9
0
 public AwesomeQueryHandler(IProjector projector, AskDbContext context) : base(projector, context)
 {
 }
示例#10
0
 public CategoryController(AskDbContext askDbContext)
 {
     this.askDbContext = askDbContext;
 }
示例#11
0
 public SyndicationQuestionsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context)
 {
 }
示例#12
0
        // Constructor

        public IndexModel(AskDbContext dc)
        {
            this._dc = dc;
        }
 public UpdateQuestionCommandHandler(AskDbContext context) : base(context)
 {
 }
示例#14
0
        // Constructor

        public HomeController(AskDbContext dc, IOptionsSnapshot <AppConfiguration> optionsSnapshot)
        {
            this._dc  = dc;
            this._cfg = optionsSnapshot.Value;
        }
示例#15
0
 public QuestionsController(AskDbContext askDbContext, IOptionsSnapshot <AppConfiguration> optionsSnapshot)
 {
     this.askDbContext     = askDbContext;
     this.appConfiguration = optionsSnapshot.Value;
 }
示例#16
0
        // Constructor

        public AdminController(AskDbContext dc, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager)
        {
            this._dc            = dc;
            this._userManager   = userManager;
            this._signInManager = signInManager;
        }
示例#17
0
        // Constructor

        public IndexModel(AskDbContext dc, IOptionsSnapshot <AppConfiguration> optionsSnapshot)
        {
            this._dc  = dc;
            this._cfg = optionsSnapshot.Value;
        }
示例#18
0
 public QuestionsViewModel(IHostingEnvironment env, IOptionsSnapshot <AppConfiguration> config, AskDbContext dbContext) : base(env, config)
 {
     this.dbContext = dbContext;
 }
 public CategoriesListItemsQueryHandler(IProjector projector, AskDbContext context) : base(projector, context)
 {
 }
示例#20
0
        // Constructor

        public QuestionModel(AskDbContext dc)
        {
            this._dc = dc;
        }
示例#21
0
        public IndexViewModel(IHostingEnvironment env, AskDbContext dbContext, IQuestions questions) : base(env)
        {
            Data.PagingOptions.PageSize = 10;

            _questions = questions;
        }