예제 #1
0
        public Group_PollViewModel(Poll poll)
        {
            Experts = new List <Group_Poll_ExpertViewModel>();

            if (poll != null)
            {
                Id         = poll.Id;
                Title      = poll.Title;
                Text       = poll.Text;
                IsFinished = poll.IsFinished;
                State      = (ContentState)poll.State;
                if (poll.GroupId.HasValue)
                {
                    GroupId = poll.GroupId.Value;
                }


                var publishData = VotingService.GetPollPublishData(poll.Id);
                if (publishData != null)
                {
                    IsCreationInProccess = true;
                    IsCreationFailed     = publishData.IsFailed;
                }

                PollStatus = new Group_PollStatusViewModel(poll);

                var totalBulletins = poll.Bulletins.Count;
                foreach (var expertBulletin in poll.Bulletins.Where(x => x.Weight > 1).OrderByDescending(x => x.Weight).Take(5))
                {
                    Experts.Add(new Group_Poll_ExpertViewModel(expertBulletin, totalBulletins));
                }
            }
        }