/// <summary> /// Gets and bulk updates badges. Called when the "Get and bulk update badges" button is pressed. /// Expects the CreateBadge method to be run first. /// </summary> private bool 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 = new BadgeInfo(badgeDr); // Update the properties modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper(); // Save the changes BadgeInfoProvider.SetBadgeInfo(modifyBadge); } return(true); } return(false); }
/// <summary> /// OK button click event handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Validate entered values string error = new Validator().IsCodeName(txtName.Text.Trim(), GetString("general.invalidcodename")) .NotEmpty(txtDisplayName.Text.Trim(), GetString("badge.errors.displayname")).Result; // Save new values if (DataHelper.IsEmpty(error)) { // Check that code name is unique BadgeInfo bi = BadgeInfoProvider.GetBadgeInfo(txtName.Text.Trim()); if ((bi == null) || ((bi != null) && (bi.BadgeID == badgeId))) { // Update existing record if (bi == null) { bi = new BadgeInfo(); } // Set properties bi.BadgeID = badgeId; bi.BadgeName = txtName.Text.Trim(); bi.BadgeDisplayName = txtDisplayName.Text.Trim(); bi.BadgeImageURL = txtImageURL.Text.Trim(); int topLimit = ValidationHelper.GetInteger(txtTopLimit.Text.Trim(), 0); if (topLimit >= 0) { bi.BadgeTopLimit = topLimit; } else { bi.BadgeTopLimit = 0; } bi.BadgeIsAutomatic = chkIsAutomatic.Checked; // Save BadgeInfo BadgeInfoProvider.SetBadgeInfo(bi); URLHelper.Redirect("~/CMSModules/Badges/Badges_Edit.aspx?saved=1&badgeid=" + bi.BadgeID); } else { lblError.ResourceString = "badge.errors.uniquecodename"; lblError.Visible = true; } } else { lblError.ResourceString = error; //badge.errors.values lblError.Visible = true; } }
/// <summary> /// Creates badge. Called when the "Create badge" button is pressed. /// </summary> private bool CreateBadge() { // Create new badge object BadgeInfo newBadge = new BadgeInfo(); // Set the properties newBadge.BadgeDisplayName = "My new badge"; newBadge.BadgeName = "MyNewBadge"; newBadge.BadgeTopLimit = 50; newBadge.BadgeImageURL = GetImageUrl("Objects/CMS_Badge/Default/siteadmin.gif"); newBadge.BadgeIsAutomatic = true; // Save the badge BadgeInfoProvider.SetBadgeInfo(newBadge); return(true); }
/// <summary> /// Gets and updates badge. Called when the "Get and update badge" button is pressed. /// Expects the CreateBadge method to be run first. /// </summary> private bool GetAndUpdateBadge() { // Get the badge BadgeInfo updateBadge = BadgeInfoProvider.GetBadgeInfo("MyNewBadge"); if (updateBadge != null) { // Update the properties updateBadge.BadgeDisplayName = updateBadge.BadgeDisplayName.ToLowerCSafe(); // Save the changes BadgeInfoProvider.SetBadgeInfo(updateBadge); return(true); } return(false); }
/// <summary> /// Gets and bulk updates badges. Called when the "Get and bulk update badges" button is pressed. /// Expects the CreateBadge method to be run first. /// </summary> private bool GetAndBulkUpdateBadges() { // Prepare the parameters string where = "BadgeName LIKE N'MyNewBadge%'"; // Get the data from database var badges = BadgeInfoProvider.GetBadges().Where(where); // Loop through the individual items foreach (BadgeInfo modifyBadge in badges) { // Update the properties modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper(); // Save the changes BadgeInfoProvider.SetBadgeInfo(modifyBadge); } // Return TRUE if any object was found and updated, FALSE otherwise return(badges.Count > 0); }