newBadge.BadgeIsAutomatic = true; // Save the badge BadgeInfoProvider.SetBadgeInfo(newBadge); }
The following example gets and updates a badge.
privatebool GetAndUpdateBadge() { // Get the badge BadgeInfo updateBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge"); if (updateBadge != null) { // Update the properties updateBadge.BadgeDisplayName = updateBadge.BadgeDisplayName.ToLower(); // Save the changes BadgeInfoProvider.SetBadgeInfo(updateBadge); returntrue; } returnfalse; }
The following example gets and bulk updates badges.
privatebool GetAndBulkUpdateBadges() { // Prepare the parameters string where = "BadgeName LIKE N'MyNewBadge%'"; // Get the data DataSet badges = BadgeInfoProvider.GetBadges(where, null); if (!DataHelper.DataSourceIsEmpty(badges)) { // Loop through the individual items foreach (DataRow badgeDr in badges.Tables[0].Rows) { // Create object from DataRow BadgeInfo modifyBadge = newBadgeInfo(badgeDr);
// Update the properties modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper();
// Save the changes BadgeInfoProvider.SetBadgeInfo(modifyBadge); } returntrue; } returnfalse; }
The following example deletes a badge.
privatebool DeleteBadge() { // Get the badge BadgeInfo deleteBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge"); // Delete the badge BadgeInfoProvider.DeleteBadgeInfo(deleteBadge); return (deleteBadge != null); }