using CMS.Polls;
using CMS.SettingsProvider;
using CMS.DataEngine;
using CMS.GlobalHelper;
...
string pollName = "testingpoll"; // Poll code name
// Get poll info for the specified code name
PollInfo pollObj = PollInfoProvider.GetPollInfo(pollName);
if (pollObj != null)
{
// Get all answers of the poll
DataSet ds = PollAnswerInfoProvider.GetAnswers(pollObj.PollID);
if (!DataHelper.DataSourceIsEmpty(ds))
{
// Get first pollanswerinfo object
PollAnswerInfo pollAnswerObj = new PollAnswerInfo(ds.Tables[0].Rows[0]);
if (pollAnswerObj != null)
{
// Increment votes by 1
pollAnswerObj.AnswerCount++;
// Save the data
PollAnswerInfoProvider.SetPollAnswerInfo(pollAnswerObj);
}
}
}
|