/// <summary> /// Run the code example. /// </summary> /// <param name="dfpUser">The DFP user object running the code example.</param> public override void Run(DfpUser dfpUser) { // Get the UserTeamAssociationService. UserTeamAssociationService userTeamAssociationService = (UserTeamAssociationService) dfpUser.GetService(DfpService.v201211.UserTeamAssociationService); // Set the users and team to add them to. long teamId = long.Parse(_T("INSERT_TEAM_ID_HERE")); long[] userIds = new long[] {long.Parse(_T("INSERT_USER_ID_HERE"))}; // Create an array to store local user team association objects. UserTeamAssociation[] userTeamAssociations = new UserTeamAssociation[userIds.Length]; // For each user, associate it with the given team. int i = 0; foreach (long userId in userIds) { UserTeamAssociation userTeamAssociation = new UserTeamAssociation(); userTeamAssociation.userId = userId; userTeamAssociation.teamId = teamId; userTeamAssociations[i++] = userTeamAssociation; } try { // Create the user team associations on the server. userTeamAssociations = userTeamAssociationService.createUserTeamAssociations(userTeamAssociations); if (userTeamAssociations != null) { foreach (UserTeamAssociation userTeamAssociation in userTeamAssociations) { Console.WriteLine("A user team association between user with ID \"{0}\" and team " + "with ID \"{1}\" was created.", userTeamAssociation.userId, userTeamAssociation.teamId); } } else { Console.WriteLine("No user team associations created."); } } catch (Exception ex) { Console.WriteLine("Failed to create user team associations. Exception says \"{0}\"", ex.Message); } }
public UserTeamAssociation updateUserTeamAssociation(UserTeamAssociation userTeamAssociation) { object[] results = this.Invoke("updateUserTeamAssociation", new object[] { userTeamAssociation }); return ((UserTeamAssociation) (results[0])); }