public static void ConfigureUsers(IEnumerable <DefaultUser> users, string connString)
        {
            using (var db = new CustomDatabase(connString))
            {
                if (!db.Users.Any())
                {
                    var repo = new CustomUserRepository(db);
                    var svc  = new CustomUserAccountService(CustomConfig.Config, repo);

                    foreach (var u in users)
                    {
                        var account = svc.CreateAccount(u.UserName, u.Password, u.Email);
                        account.FirstName = u.FirstName;
                        account.LastName  = u.LastName;
                        account.Age       = u.Age;
                        svc.Update(account);

                        foreach (var role in u.Roles)
                        {
                            svc.AddClaim(account.ID, IdentityManager.Constants.ClaimTypes.Role, role);
                        }
                    }
                    db.SaveChanges();
                }
            }
        }
示例#2
0
 public CustomIdentityManagerService(CustomUserAccountService userSvc, CustomGroupService groupSvc)
     : base(userSvc, groupSvc)
 {
 }