privatevoid CreateWidgetCategory() { // Create new widget category object WidgetCategoryInfo newCategory = newWidgetCategoryInfo(); // Set the properties newCategory.WidgetCategoryDisplayName = "My new category"; newCategory.WidgetCategoryName = "MyNewCategory"; // Save the widget category WidgetCategoryInfoProvider.SetWidgetCategoryInfo(newCategory); }
The following example gets and updates a widget category.
privatebool GetAndUpdateWidgetCategory() {
// Get the widget category WidgetCategoryInfo updateCategory = WidgetCategoryInfoProvider.GetWidgetCategoryInfo("MyNewCategory");
if (updateCategory != null) {
// Update the properties updateCategory.WidgetCategoryDisplayName = updateCategory.WidgetCategoryDisplayName.ToLower();
// Save the changes WidgetCategoryInfoProvider.SetWidgetCategoryInfo(updateCategory); returntrue; } returnfalse; }
The following example gets and bulk updates widget categories.
privatebool GetAndBulkUpdateWidgetCategories() { // Prepare the parameters string where = "WidgetCategoryName LIKE N'MyNewCategory%'"; string orderBy = ""; int topN = 0; string columns = "";
// Get the data DataSet categories = WidgetCategoryInfoProvider.GetWidgetCategories(where, orderBy, topN, columns);
if (!DataHelper.DataSourceIsEmpty(categories)) { // Loop through the individual items foreach (DataRow categoryDr in categories.Tables[0].Rows) { // Create object from DataRow WidgetCategoryInfo modifyCategory = newWidgetCategoryInfo(categoryDr);
// Update the properties modifyCategory.WidgetCategoryDisplayName = modifyCategory.WidgetCategoryDisplayName.ToUpper();
// Save the changes WidgetCategoryInfoProvider.SetWidgetCategoryInfo(modifyCategory); } returntrue; } returnfalse; }
The following example deletes a widget category.
privatebool DeleteWidgetCategory() {
// Get the widget category WidgetCategoryInfo deleteCategory = WidgetCategoryInfoProvider.GetWidgetCategoryInfo("MyNewCategory");