public List<QuickPollVotes> GetPollResult(int pollID) { QuickPollResult quickPollResult = new QuickPollResult(); QuickPollOptions quickPollOption = new QuickPollOptions(); List<QuickPollVotes> voteCollection = new List<QuickPollVotes>(); using (var pollOptions = DynamicDataStoreFactory.Instance.GetStore(typeof(QuickPollOptions))) { quickPollOption = pollOptions.Find<QuickPollOptions>("PollID", pollID).FirstOrDefault(); } using (var pollResults = DynamicDataStoreFactory.Instance.GetStore(typeof(QuickPollResult))) { var pollResultObjects = pollResults.Find<QuickPollResult>("MainPollID", pollID); if (pollResultObjects != null) { var totalCount = pollResultObjects.Count(); if (quickPollOption.Option1 != null) { var vote1 = GetQuickPollVote(quickPollOption.Option1, pollResultObjects); voteCollection.Add(vote1); } if (quickPollOption.Option2 != null) { var vote2 = GetQuickPollVote(quickPollOption.Option2, pollResultObjects); voteCollection.Add(vote2); } if (quickPollOption.Option3 != null) { var vote3 = GetQuickPollVote(quickPollOption.Option3, pollResultObjects); voteCollection.Add(vote3); } if (quickPollOption.Option4 != null) { var vote4 = GetQuickPollVote(quickPollOption.Option4, pollResultObjects); voteCollection.Add(vote4); } if (quickPollOption.Option5 != null) { var vote5 = GetQuickPollVote(quickPollOption.Option5, pollResultObjects); voteCollection.Add(vote5); } if (quickPollOption.Option6 != null) { var vote6 = GetQuickPollVote(quickPollOption.Option6, pollResultObjects); voteCollection.Add(vote6); } if (quickPollOption.Option7 != null) { var vote7 = GetQuickPollVote(quickPollOption.Option7, pollResultObjects); voteCollection.Add(vote7); } if (quickPollOption.Option8 != null) { var vote8 = GetQuickPollVote(quickPollOption.Option8, pollResultObjects); voteCollection.Add(vote8); } if (quickPollOption.Option9 != null) { var vote9 = GetQuickPollVote(quickPollOption.Option9, pollResultObjects); voteCollection.Add(vote9); } if (quickPollOption.Option10 != null) { var vote10 = GetQuickPollVote(quickPollOption.Option10, pollResultObjects); voteCollection.Add(vote10); } } } return voteCollection; }
public void SavePollVotes(int pollID, string voteOption) { var currentPoll = GetPoll(pollID); var quickPoll = new QuickPollResult() { Id = Identity.NewIdentity(Guid.NewGuid()), MainPollID = Convert.ToString(pollID), UserName = System.Web.HttpContext.Current.User.Identity.Name, OptionID = voteOption }; var quickPollResultStore = DynamicDataStoreFactory.Instance.GetStore(typeof(QuickPollResult)); quickPollResultStore.Save(quickPoll); }