protected void ButtonAddMembership_OnClick(Object Sender, EventArgs eventArgs) { if (MercuryApplication == null) { return; } SaveResponseLabel.Text = String.Empty; if (WorkTeamMembershipAccountSelection.SelectedItem != null) { if ((!String.IsNullOrEmpty(WorkTeamMembershipAccountSelection.SelectedValue)) && (WorkTeamMembershipAccountSelection.SelectedItem != null)) { Int64 securityAuthorityId = Convert.ToInt64(WorkTeamMembershipAccountSelection.SelectedValue.Split('|')[0]); String userAccountId = WorkTeamMembershipAccountSelection.SelectedValue.Split('|')[1]; String userAccountName = WorkTeamMembershipAccountSelection.SelectedValue.Split('|')[2]; String userDisplayName = WorkTeamMembershipAccountSelection.SelectedItem.Text.Split(':')[1].Trim(); Server.Application.WorkTeamRole teamRole = (Mercury.Server.Application.WorkTeamRole)Convert.ToInt32(WorkTeamMembershipTeamRole.SelectedValue); if (!workTeam.ContainsMembership(securityAuthorityId, userAccountId)) { workTeam.AddMembership(securityAuthorityId, WorkTeamMembershipAccountSelection.SelectedItem.Text.Split(':')[0], userAccountId, userAccountName, userDisplayName, teamRole); } else { SaveResponseLabel.Text = "Cannot add duplicate member to team."; } } else { SaveResponseLabel.Text = "No Member Selected to Add."; } } else { SaveResponseLabel.Text = "No Member Selected to Add."; } InitializeMembershipGrid(); InitializeMembershipPage(); return; }
public void AddMembership(Int64 securityAuthorityId, String securityAuthorityName, String userAccountId, String userAccountName, String userDisplayName, Server.Application.WorkTeamRole workTeamRole) { if (!ContainsMembership(securityAuthorityId, userAccountId)) { Server.Application.WorkTeamMembership newMembership = new Server.Application.WorkTeamMembership(); newMembership.WorkTeamId = Id; newMembership.SecurityAuthorityId = securityAuthorityId; newMembership.SecurityAuthorityName = securityAuthorityName; newMembership.UserAccountId = userAccountId; newMembership.UserAccountName = userAccountName; newMembership.UserDisplayName = userDisplayName; newMembership.WorkTeamRole = workTeamRole; newMembership.CreateAccountInfo = this.createAccountInfo; newMembership.ModifiedAccountInfo = this.modifiedAccountInfo; membership.Add(newMembership); } return; }