/// <summary> /// Gets and bulk updates answers. Called when the "Get and bulk update answers" button is pressed. /// Expects the CreateAnswer method to be run first. /// </summary> private bool GetAndBulkUpdateAnswers() { PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID); if (updatePoll != null) { // Get the data DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID); if (!DataHelper.DataSourceIsEmpty(answers)) { // Loop through the individual items foreach (DataRow answerDr in answers.Tables[0].Rows) { // Create object from DataRow PollAnswerInfo modifyAnswer = new PollAnswerInfo(answerDr); // Update the properties modifyAnswer.AnswerText = modifyAnswer.AnswerText.ToUpper(); // Save the changes PollAnswerInfoProvider.SetPollAnswerInfo(modifyAnswer); } return(true); } } return(false); }
/// <summary> /// Gets and updates answer. Called when the "Get and update answer" button is pressed. /// Expects the CreateAnswer method to be run first. /// </summary> private bool GetAndUpdateAnswer() { // Get the answer PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID); if (updatePoll != null) { DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID, 1, null); if (!DataHelper.DataSourceIsEmpty(answers)) { PollAnswerInfo updateAnswer = new PollAnswerInfo(answers.Tables[0].Rows[0]); // Update the properties updateAnswer.AnswerText = updateAnswer.AnswerText.ToLower(); // Save the changes PollAnswerInfoProvider.SetPollAnswerInfo(updateAnswer); return(true); } } return(false); }
/// <summary> /// Deletes answer. Called when the "Delete answer" button is pressed. /// Expects the CreateAnswer method to be run first. /// </summary> private bool DeleteAnswer() { // Get the poll PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID); if (updatePoll != null) { // Get the answer DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID, 1, null); if (!DataHelper.DataSourceIsEmpty(answers)) { PollAnswerInfo deleteAnswer = new PollAnswerInfo(answers.Tables[0].Rows[0]); // Delete the answer PollAnswerInfoProvider.DeletePollAnswerInfo(deleteAnswer); return(deleteAnswer != null); } } return(false); }