Пример #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,
                              AccountSeed accountSeed)
        {
            AutofacContainer = app.ApplicationServices.GetAutofacRoot();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();
            app.UseSession();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "areas",
                    pattern: "{area:exists}/{controller=Dashboard}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            accountSeed.MigrateAsync().Wait();
            accountSeed.SeedAsync().Wait();
        }
Пример #2
0
        internal bool AddSeed(IKey key, byte[] seed)
        {
            AccountIdentity identity = GetAccountIdentity(key);

            if (identity != null)
            {
                lock (_sync)
                {
                    AccountSeed accountSeed = _dataContext.AccountSeeds.FirstOrDefault(s => s.Identity == identity);
                    if (accountSeed == null)
                    {
                        accountSeed = new AccountSeed {
                            Identity = identity, Seed = seed
                        };
                        _dataContext.AccountSeeds.Add(accountSeed);
                    }

                    return(true);
                }
            }

            return(false);
        }