Esempio n. 1
0
        private static void CreateAdministratorAspNetGroup(UserManager <AspNetUser> userManager, RoleManager <AspNetRole> roleManager)
        {
            IdentityRepository repo = new IdentityRepository(context, userManager);

            AspNetGroup aspNetGroup = new AspNetGroup();

            aspNetGroup.Name        = "Administrator";
            aspNetGroup.Description = "Administrator";
            aspNetGroup.Active      = true;
            var groupId = repo.AddGroup(aspNetGroup);

            AspNetRole adminRole = roleManager.FindByNameAsync("Administrator").Result;

            AspNetRoleGroup aspNetRoleGroup = new AspNetRoleGroup();

            aspNetRoleGroup.GroupId = groupId;
            aspNetRoleGroup.RoleId  = adminRole.Id;
            aspNetRoleGroup.Allow   = true;

            repo.AddRoleToGroup(aspNetRoleGroup);
        }