/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create ContentCategoryRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService)user.GetService( DfaService.v1_20.ContentCategoryRemoteService); string contentCategoryName = _T("INSERT_CONTENT_CATEGORY_NAME_HERE"); // Create content category structure. ContentCategory contentCategory = new ContentCategory(); contentCategory.id = 0; contentCategory.name = contentCategoryName; try { // Create content category. ContentCategorySaveResult contentCategorySaveResult = service.saveContentCategory(contentCategory); // Display content category id. Console.WriteLine("Content category with id \"{0}\" was created.", contentCategorySaveResult.id); } catch (Exception e) { Console.WriteLine("Failed to add content category. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create CreativeRemoteService instance. ContentCategoryRemoteService service = (ContentCategoryRemoteService) user.GetService( DfaService.v1_20.ContentCategoryRemoteService); String searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create content category search criteria structure. ContentCategorySearchCriteria searchCriteria = new ContentCategorySearchCriteria(); searchCriteria.pageSize = 10; searchCriteria.searchString = searchString; try { // Get content category record set. ContentCategoryRecordSet contentCategoryRecordSet = service.getContentCategories(searchCriteria); // Display content category names, ids and descriptions. if (contentCategoryRecordSet != null && contentCategoryRecordSet.records != null) { foreach (ContentCategory contentCategory in contentCategoryRecordSet.records) { Console.WriteLine("Content category with name \"{0}\" and id \"{1}\" was found.", contentCategory.name, contentCategory.id); } } else { Console.WriteLine("No content categories found for your search criteria."); } } catch (Exception e) { Console.WriteLine("Failed to get content categories. Exception says \"{0}\"", e.Message); } }