Exemple #1
0
        private void SeedUsers(UserManager <AppUser> userManager)
        {
            var superAdminSettings = new SuperAdminSettings();

            _configuration.GetSection(nameof(SuperAdminSettings)).Bind(superAdminSettings);
            UsersSeed.Seed(userManager, superAdminSettings);
        }
        private static async Task SeedIdentity(IHost host)
        {
            using var serviceScope = host.Services.CreateScope();

            var roleManager = serviceScope.ServiceProvider
                              .GetRequiredService <RoleManager <IdentityRole> >();

            var userManager = serviceScope.ServiceProvider
                              .GetRequiredService <UserManager <IdentityUser> >();

            await RolesSeed.Seed(roleManager);

            await UsersSeed.Seed(userManager);
        }
Exemple #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            //if (env.IsDevelopment())
            //{
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
            //}
            //else
            //{
            //    app.UseExceptionHandler("/Home/Error");
            //}

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            IServiceScopeFactory scopeFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>();

            using (IServiceScope scope = scopeFactory.CreateScope())
            {
                var profilesRepository = scope.ServiceProvider.GetRequiredService <IProfilesRepository>();
                ProfilesSeed.Seed(profilesRepository);

                var userManager = scope.ServiceProvider.GetRequiredService <UserManager <ApplicationUser> >();
                var roleManager = scope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >();

                var usersSeed = new UsersSeed(profilesRepository);
                usersSeed.Seed(userManager).Wait();

                RolesSeed.Seed(roleManager).Wait();
                UserRolesSeed.Seed(userManager).Wait();
            }
        }
Exemple #4
0
 /**
  * USERS
  */
 public void SeedUsers()
 {
     Users = UsersSeed.Seed();
 }