private void SeedAuthUserDomain(User admin) { var pendingRegistrationRole = RoleTestHelper.PendingRegistration().Build(); var registeredUserRole = RoleTestHelper.RegisteredUser().Build(); var adminRole = RoleTestHelper.Admin().Build(); var adminAuthUser = AuthUserTestHelper.FromUserAndRoles(admin, registeredUserRole, adminRole).Build(); _unitOfWork.WithAuthUserTransaction(tran => { _roleRepository.Save(pendingRegistrationRole); _roleRepository.Save(registeredUserRole); _roleRepository.Save(adminRole); _authUserRepository.Save(adminAuthUser); tran.Commit(); }); }
private void SeedAuthUserDomain(IReadOnlyList <User> users) { _unitOfWork.WithAuthUserTransaction(tran => { var roles = _roleRepository.List(); var pendingRegistrationRole = roles.Single(r => r.Rolename == Role.PENDING_REGISTRATION_ROLENAME); var registeredUserRole = roles.Single(r => r.Rolename == Role.REGISTERED_USER_ROLENAME); var adminRole = roles.Single(r => r.Rolename == Role.ADMIN_ROLENAME); foreach (var u in users) { var role = u.Username == "PendingPlayer" ? pendingRegistrationRole : registeredUserRole; var authUserBuilder = AuthUserTestHelper.FromUserAndRoles(u, role).WithPasswordHash("admin"); if (u.Username == Username.MATTY) { authUserBuilder.AddRole(adminRole); } _authUserRepository.Save(authUserBuilder.Build()); } tran.Commit(); }); }