Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        private void SaveQuickPollObjects(QuickPollBlock currentBlock)
        {
            var quickPoll = new QuickPollObjects()
            {
                Id = Identity.NewIdentity(Guid.NewGuid()),
                PollID = (currentBlock as IContent).ContentLink.ID,
                Title = currentBlock.QuickPollHeading,
                Question = currentBlock.Question,
                CreatedBy = System.Web.HttpContext.Current.User.Identity.Name,
                IsActive = true
            };

            var quickPollStore = DynamicDataStoreFactory.Instance.GetStore(typeof(QuickPollObjects));
            quickPollStore.Save(quickPoll);

            var quickPollOptions = new QuickPollOptions()
            {
                Id = Identity.NewIdentity(Guid.NewGuid()),
                PollID = Convert.ToString((currentBlock as IContent).ContentLink.ID),
                Option1 = currentBlock.Alternative1,
                Option2 = currentBlock.Alternative2,
                Option3 = currentBlock.Alternative3,
                Option4 = currentBlock.Alternative4,
                Option5 = currentBlock.Alternative5,
                Option6 = currentBlock.Alternative6,
                Option7 = currentBlock.Alternative7,
                Option8 = currentBlock.Alternative8,
                Option9 = currentBlock.Alternative9,
                Option10 = currentBlock.Alternative10
            };

            var quickPollOptionsStores = DynamicDataStoreFactory.Instance.GetStore(typeof(QuickPollOptions));
            quickPollOptionsStores.Save(quickPollOptions);
        }