public static void ExecuteMethod_RemoveAccountToBeMergedFromAllGroups(TBRAccountRoot accountToBeMerged, TBAccountCollaborationGroup[] groupAccessToBeMerged) { var accountID = accountToBeMerged.ID; var groupIDs = groupAccessToBeMerged.Select(colGrp => colGrp.GroupID).ToArray(); foreach (var groupID in groupIDs) { RemoveMemberFromGroup.Execute(new RemoveMemberFromGroupParameters { AccountID = accountID, GroupID = groupID }); } }
public static void ExecuteMethod_UpdateAccountRootGroupMemberships(TBRGroupRoot groupRoot, TBRAccountRoot accountRoot) { string[] accountEmailAddresses = accountRoot.Account.Emails.CollectionContent.Select(email => email.EmailAddress).ToArray(); var accountRoles = groupRoot.Group.Roles.CollectionContent.Where( role => accountEmailAddresses.Contains(role.Email.EmailAddress)).ToArray(); accountRoot.Account.GroupRoleCollection.CollectionContent.RemoveAll( currRole => currRole.GroupID == groupRoot.Group.ID); var acctCollaborationRoles = accountRoles. Select(grpRole => { TBAccountCollaborationGroup acctGroup = TBAccountCollaborationGroup.CreateDefault(); acctGroup.GroupID = groupRoot.Group.ID; acctGroup.GroupRole = grpRole.Role; acctGroup.RoleStatus = grpRole.RoleStatus; return(acctGroup); }); accountRoot.Account.GroupRoleCollection.CollectionContent.AddRange(acctCollaborationRoles); }
public static void ExecuteMethod_AddPrimaryAccountToAllGroupsWhereItsMissing(TBRAccountRoot primaryAccountToStay, TBAccountCollaborationGroup[] groupAccessToBeMerged) { string memberEmailAddress = primaryAccountToStay.Account.Emails.CollectionContent.FirstOrDefault().EmailAddress; foreach (var groupAccess in groupAccessToBeMerged) { TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupAccess.GroupID); TBCollaboratorRole role = groupRoot.Group.Roles.CollectionContent.FirstOrDefault( candidate => candidate.Email.EmailAddress == memberEmailAddress); if (role != null) { continue; } else { role = TBCollaboratorRole.CreateDefault(); role.Email.EmailAddress = memberEmailAddress; role.Role = TBCollaboratorRole.CollaboratorRoleValue; role.SetRoleAsMember(); groupRoot.Group.Roles.CollectionContent.Add(role); } groupRoot.StoreInformation(); } }
public static void ExecuteMethod_ValidateAccountToBeMerged(TBAccountCollaborationGroup[] groupAccessToBeMerged, TBAccountCollaborationGroup[] groupInitiatorAccessToBeTransfered, TBEmail[] emailAddressesToBeMerged) { if(groupAccessToBeMerged.Length > 0 || groupInitiatorAccessToBeTransfered.Length > 0 || emailAddressesToBeMerged.Length > 0) throw new NotSupportedException("Account merge not supported for account that is member of any groups or contains email addresses of its own"); }
public static void ExecuteMethod_TransferGroupInitiatorRights(string primaryAccountToStayId, string accountToBeMergedAndDestroyedId, TBAccountCollaborationGroup[] groupInitiatorAccessToBeTransfered) { foreach (var groupAccess in groupInitiatorAccessToBeTransfered) { var groupID = groupAccess.GroupID; TransferGroupInitiator.Execute(new TransferGroupInitiatorParameters { GroupID = groupID, NewInitiatorAccountID = primaryAccountToStayId, OldInitiatorAccountID = accountToBeMergedAndDestroyedId }); } }