示例#1
0
        public Group_Poll_ExpertViewModel(PollBulletin bulletin, int totalBulletins)
        {
            if (bulletin != null)
            {
                Id = bulletin.Owner.UserId;
                var expert = bulletin.Owner.User;
                Name       = expert.FirstName;
                Surname    = expert.SurName;
                Patronymic = expert.Patronymic;
                Avatar     = ImageService.GetImageUrl <User>(expert.Avatar);

                Represent = bulletin.Weight;
                double weight = Represent;
                RelativeRepresent = Math.Round((100 * weight / totalBulletins), 2);
                Comment           = bulletin.Comment;

                switch ((VoteOption)bulletin.Result)
                {
                case VoteOption.Yes: VoteResult = "<span class='vote yes'>За</span>"; break;

                case VoteOption.No: VoteResult = "<span class='vote no'>Против</span>"; break;

                case VoteOption.Refrained: VoteResult = "<span class='vote forefit'>Воздержался</span>"; break;

                case VoteOption.NotVoted: VoteResult = "<span class='vote not'>Не голосовал</span>"; break;
                }
            }
        }
        public GroupOpenPollReport_BulletinViewModel(PollBulletin bulletin)
        {
            if (bulletin == null)
            {
                return;
            }

            Name   = bulletin.Owner.User.FullName;
            Result = (VoteOption)bulletin.Result;
        }
        public GroupPollReport_BulletinViewModel(PollBulletin bulletin)
        {
            if (bulletin == null)
            {
                return;
            }

            Id     = bulletin.Id;
            Weight = bulletin.Weight;
            Result = (VoteOption)bulletin.Result;
        }
        public Group_PollVotePanel_ExpertViewModel(PollBulletin expertBulletin)
        {
            if (expertBulletin != null)
            {
                var expert = expertBulletin.Owner.User;
                Id         = expert.Id;
                Name       = expert.FirstName;
                SurName    = expert.SurName;
                Patronymic = expert.Patronymic;
                Avatar     = ImageService.GetImageUrl <User>(expert.Avatar);

                switch ((VoteOption)expertBulletin.Result)
                {
                case VoteOption.Yes: VoteResult = "<span class='vote yes'>За</span>"; break;

                case VoteOption.No: VoteResult = "<span class='vote no'>Против</span>"; break;

                case VoteOption.Refrained: VoteResult = "<span class='vote forefit'>Воздержался</span>"; break;

                case VoteOption.NotVoted: VoteResult = "<span class='vote not'>Не голосовал</span>"; break;
                }
            }
        }