/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="dfpUser">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the UserTeamAssociationService.
      UserTeamAssociationService userTeamAssociationService =
          (UserTeamAssociationService) user.GetService(
              DfpService.v201405.UserTeamAssociationService);

      // Set the ID of the user to fetch all user team associations for.
      long userId = long.Parse(_T("INSERT_USER_ID_HERE"));

      // Create statement to select user team associations by the user ID.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("userId = :userId")
          .OrderBy("id ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("userId", userId);

      // Set default for page.
      UserTeamAssociationPage page = new UserTeamAssociationPage();

      try {
        do {
          // Get user team associations by statement.
          page = userTeamAssociationService.getUserTeamAssociationsByStatement(
              statementBuilder.ToStatement());

          // Display results.
          if (page.results != null) {
            int i = page.startIndex;
            foreach (UserTeamAssociation userTeamAssociation in page.results) {
              Console.WriteLine("{0}) User team association between user with ID \"{1}\" and " +
                  "team with ID \"{2}\" was found.", i, userTeamAssociation.userId,
                  userTeamAssociation.teamId);
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while(statementBuilder.GetOffset() < page.totalResultSetSize);
        Console.WriteLine("Number of results found: " + page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get user team associations. Exception says \"{0}\"",
            ex.Message);
      }
    }
    /// <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.v201405.UserTeamAssociationService);

      // Set defaults for page and filterStatement.
      UserTeamAssociationPage page = new UserTeamAssociationPage();
      Statement filterStatement = new Statement();
      int offset = 0;

      try {
        do {
          // Create a statement to get all user team associations.
          filterStatement.query = "LIMIT 500 OFFSET " + offset;

          // Get user team associations by statement.
          page = userTeamAssociationService.getUserTeamAssociationsByStatement(filterStatement);

          if (page.results != null) {
            int i = page.startIndex;
            foreach (UserTeamAssociation userTeamAssociation in page.results) {
              Console.WriteLine("{0}) User team association between user with ID \"{1}\" and " +
                  "team with ID \"{2}\" was found.", i, userTeamAssociation.userId,
                  userTeamAssociation.teamId);
              i++;
            }
          }

          offset += 500;
        } while (offset < page.totalResultSetSize);

        Console.WriteLine("Number of results found: {0}." + page.totalResultSetSize);
      } catch (Exception ex) {
        Console.WriteLine("Failed to get user team associations. Exception says \"{0}\"",
            ex.Message);
      }
    }
    /// <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.v201405.UserTeamAssociationService);

      // Set the user to remove from its teams.
      long userId = long.Parse(_T("INSERT_USER_ID_HERE"));

      // Create filter text to select user team associations by the user ID.
      StatementBuilder statementBuilder = new StatementBuilder()
          .Where("userId = :userId")
          .OrderBy("userId ASC, teamId ASC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .AddValue("userId", userId);

      // Set default for page.
      UserTeamAssociationPage page = new UserTeamAssociationPage();

      try {
        do {
          // Get user team associations by statement.
          page = userTeamAssociationService.getUserTeamAssociationsByStatement(
              statementBuilder.ToStatement());

          if (page.results != null) {
            int i = page.startIndex;
            foreach (UserTeamAssociation userTeamAssociation in page.results) {
              Console.WriteLine("{0}) User team association between user with ID \"{1}\" and " +
                  "team with ID \"{2}\" will be deleted.", i, userTeamAssociation.userId,
                  userTeamAssociation.teamId);
              i++;
            }
          }

          statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
        } while (statementBuilder.GetOffset() < page.totalResultSetSize);

        Console.WriteLine("Number of teams that the user will be removed from: "
            + page.totalResultSetSize);

        if (page.totalResultSetSize > 0) {
          // Modify statement for action.
          statementBuilder.RemoveLimitAndOffset();

          // Create action.
          DeleteUserTeamAssociations action = new DeleteUserTeamAssociations();

          // Perform action.
          UpdateResult result = userTeamAssociationService.performUserTeamAssociationAction(action,
              statementBuilder.ToStatement());

          // Display results.
          if (result != null && result.numChanges > 0) {
            Console.WriteLine("Number of teams that the user was removed from: "
                + result.numChanges);
          } else {
            Console.WriteLine("No user team associations were deleted.");
          }
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to delete user team associations. Exception says \"{0}\"",
            ex.Message);
      }
    }