// Set the properties newPoll.PollDisplayName = "My new poll"; newPoll.PollCodeName = "MyNewPoll"; newPoll.PollTitle = "My title"; newPoll.PollQuestion = "My question"; newPoll.PollResponseMessage = "My response message."; newPoll.PollAllowMultipleAnswers = false; newPoll.PollAccess = 0;
// Save the poll PollInfoProvider.SetPollInfo(newPoll);
returntrue; }
The following example gets and updates a poll.
privatebool GetAndUpdatePoll() { // Get the poll PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll");
if (updatePoll != null) { // Update the properties updatePoll.PollDisplayName = updatePoll.PollDisplayName.ToLower();
// Save the changes PollInfoProvider.SetPollInfo(updatePoll);
returntrue; }
returnfalse; }
The following example gets and bulk updates polls.
privatebool GetAndBulkUpdatePolls() { // Prepare the parameters string where = "PollCodeName LIKE N'MyNewPoll%'";
// Get the data DataSet polls = PollInfoProvider.GetPolls(where, null);
if (!DataHelper.DataSourceIsEmpty(polls)) { // Loop through the individual items foreach (DataRow pollDr in polls.Tables[0].Rows) { // Create object from DataRow PollInfo modifyPoll = newPollInfo(pollDr);
// Update the properties modifyPoll.PollDisplayName = modifyPoll.PollDisplayName.ToUpper();
// Save the changes PollInfoProvider.SetPollInfo(modifyPoll); }
returntrue; }
returnfalse; }
The following example adds a poll to site.
privatebool AddPollToSite() { // Get the poll PollInfo poll = PollInfoProvider.GetPollInfo("MyNewPoll");
if (poll != null) { int pollId = poll.PollID; int siteId = CMSContext.CurrentSiteID;
// Save the binding PollSiteInfoProvider.AddPollToSite(pollId, siteId);
returntrue; }
returnfalse; }
The following example removes a poll from site.
privatebool RemovePollFromSite() { // Get the poll PollInfo removePoll = PollInfoProvider.GetPollInfo("MyNewPoll");
if (removePoll != null) { // Remove poll from site PollSiteInfoProvider.RemovePollFromSite(removePoll.PollID, CMSContext.CurrentSiteID);
returntrue; }
returnfalse; }
The following example deletes a poll.
privatebool DeletePoll() { // Get the poll PollInfo deletePoll = PollInfoProvider.GetPollInfo("MyNewPoll");
// Delete the poll PollInfoProvider.DeletePollInfo(deletePoll);