public PollWrapper(FeedPoll poll) { Voted = poll.IsUserVote(SecurityContext.CurrentAccount.ID.ToString()); if (Voted) { //Get results } StartDate = (ApiDateTime)poll.StartDate; EndDate = (ApiDateTime)poll.EndDate; PollType = poll.PollType; Votes = poll.Variants.Select(x => new VoteWrapper() { Id = x.ID, Name = x.Name, Votes = poll.GetVariantVoteCount(x.ID) }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { var storage = FeedStorageFactory.Create(); var polls = storage.GetFeeds(FeedType.Poll, Guid.Empty, 1, 0); if (0 < polls.Count) { poll = storage.GetFeed(polls[0].Id) as FeedPoll; } } catch { } if (poll == null) { return; } bool isMakeVote = TenantUtil.DateTimeNow() <= poll.EndDate && !poll.IsUserVote(SecurityContext.CurrentAccount.ID.ToString()); pollForm.VoteHandlerType = typeof(PollVoteHandler); pollForm.Answered = !isMakeVote || SecurityContext.DemoMode || (SetupInfo.WorkMode == WorkMode.Promo); pollForm.Name = poll.Caption.HtmlEncode(); pollForm.PollID = poll.Id.ToString(CultureInfo.CurrentCulture); pollForm.Singleton = (poll.PollType == FeedPollType.SimpleAnswer); pollForm.AdditionalParams = poll.Id.ToString(CultureInfo.CurrentCulture); foreach (var variant in poll.Variants) { pollForm.AnswerVariants.Add(new PollForm.AnswerViarint() { ID = variant.ID.ToString(CultureInfo.CurrentCulture), Name = variant.Name, VoteCount = poll.GetVariantVoteCount(variant.ID) }); } }