private static Guid SetupOrganization(IEnumerable <AssessmentDefinitionDto> assessmentDefinitionDtos, out Guid staffKey) { var organization = new Organization("Safe Harbor"); var identity = new ClaimsIdentity(new List <Claim> { new Claim(ProCenterClaimType.OrganizationKeyClaimType, organization.Key.ToString()) }); var currentPrincipal = new ClaimsPrincipal(identity); Thread.CurrentPrincipal = currentPrincipal; organization.AddAddress(new OrganizationAddress(OrganizationAddressType.Office, new Address("123 Main Street", "", "Columbia", UnitedStates.Maryland, new PostalCode("12345")))); organization.AddPhone(new OrganizationPhone(OrganizationPhoneType.Office, new Phone("1234567890"))); foreach (var assessmentDefinitionDto in assessmentDefinitionDtos) { organization.AddAssessmentDefinition(assessmentDefinitionDto.Key); } { var staff = new Staff(organization.Key, new PersonName("Leo", "Smith")); staffKey = staff.Key; var systemAccount = new SystemAccount(organization.Key, "*****@*****.**", new Email("*****@*****.**")); var role = new Role("Organization Admin"); var permissionDescriptors = IoC.CurrentContainer.ResolveAll <IPermissionDescriptor>(); var type = typeof(BasicAccessPermissionDescriptor); var allPermissions = new List <Permission>(); foreach (var resource in permissionDescriptors.OfType <IInternalPermissionDescriptor>().Where(pd => !pd.IsInternal).SelectMany(pd => pd.Resources)) { GetPermissionsHelper(allPermissions, resource); } if (allPermissions.Count == 0) { allPermissions.Add(BasicAccessPermission.AccessUserInterfacePermission); allPermissions.Add(PatientPermission.PatientEditPermission); allPermissions.Add(PatientPermission.PatientViewPermission); allPermissions.Add(StaffPermission.StaffAddRolePermission); allPermissions.Add(StaffPermission.StaffCreateAccountPermission); allPermissions.Add(StaffPermission.StaffEditPermission); allPermissions.Add(StaffPermission.StaffLinkAccountPermission); allPermissions.Add(StaffPermission.StaffRemoveRolePermission); allPermissions.Add(StaffPermission.StaffViewPermission); allPermissions.Add(OrganizationPermission.OrganizationEditPermission); allPermissions.Add(OrganizationPermission.OrganizationViewPermission); allPermissions.Add(RolePermission.RoleAddPermissionPermission); allPermissions.Add(RolePermission.RoleEditPermission); allPermissions.Add(RolePermission.RoleRemovePermissionPermission); allPermissions.Add(RolePermission.RoleViewPermission); allPermissions.Add(TeamPermission.TeamEditPermission); allPermissions.Add(TeamPermission.TeamViewPermission); allPermissions.Add(AssessmentPermission.AssessmentEditPermission); allPermissions.Add(AssessmentPermission.AssessmentViewPermission); } foreach (var permission in allPermissions) { role.AddPermision(permission); } systemAccount.AddRole(role.Key); systemAccount.AssignToStaff(staff.Key); } { var staff = new Staff(organization.Key, new PersonName("Cindy", "Thomas")); var systemAccount = new SystemAccount(organization.Key, "*****@*****.**", new Email("*****@*****.**")); var role = new Role("Organization Viewer"); role.AddPermision(BasicAccessPermission.AccessUserInterfacePermission); role.AddPermision(PatientPermission.PatientViewPermission); role.AddPermision(AssessmentPermission.AssessmentViewPermission); role.AddPermision(StaffPermission.StaffViewPermission); systemAccount.AddRole(role.Key); systemAccount.AssignToStaff(staff.Key); } return(organization.Key); }