コード例 #1
0
ファイル: DbInitializer.cs プロジェクト: ttufekci/DashCore
        public static async void StaticInitialize(CustomConnectionContext paramContext,
                                                  UserManager <ApplicationUser> paramUserManager,
                                                  RoleManager <IdentityRole> paramRoleManager,
                                                  IConfiguration configuration)
        {
            //create database schema if none exists
            paramContext.Database.EnsureCreated();

            //If there is already an Administrator role, abort
            if (paramContext.Roles.Any(r => r.Name == "Administrator"))
            {
                return;
            }

            var user      = "******";
            var adminpass = configuration["AppSettings:AdminDefaultPass"];
            var password  = "******";

            if (!string.IsNullOrEmpty(adminpass))
            {
                password = adminpass;
            }

            var identityResult = await paramUserManager.CreateAsync(new ApplicationUser { UserName = user, Email = user, EmailConfirmed = true }, password);

            //Create the Administartor Role
            await paramRoleManager.CreateAsync(new IdentityRole("Administrator"));

            //Create the default Admin account and apply the Administrator role

            var userCreated = await paramUserManager.FindByNameAsync(user);

            await paramUserManager.AddToRoleAsync(userCreated, "Administrator");
        }
コード例 #2
0
ファイル: DbInitializer.cs プロジェクト: ttufekci/DashCore
 public DbInitializer(
     CustomConnectionContext context,
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     IConfiguration Configuration)
 {
     _context       = context;
     _userManager   = userManager;
     _roleManager   = roleManager;
     _configuration = Configuration;
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: ttufekci/DashCore
 public HomeController(CustomConnectionContext context, IUtil util)
 {
     _context = context;
     _util    = util;
 }
コード例 #4
0
 public Util(CustomConnectionContext context)
 {
     _context = context;
 }
コード例 #5
0
 public CustomConnectionsController(CustomConnectionContext context)
 {
     _context = context;
 }