public GroupSurveyResults_BulletinViewModel(SurveyBulletin bulletin, bool hasOpenProtocol)
        {
            if (bulletin == null)
                return;

            Name = hasOpenProtocol ? bulletin.User.FullName : bulletin.Id.ToString();
            Results = bulletin.Result.Select(x => x.Title).ToList();
        }
Пример #2
0
        private static Survey SurveyVote(Survey survey, ICollection<Option> options, Guid userId)
        {
            if (survey.IsFinished)
                throw new BusinessLogicException("Опрос уже завершен");
            if (survey.IsPrivate)
                GroupService.UserInGroup(userId, survey.Group, true);

            var bulletin = survey.Bulletins.SingleOrDefault(x => x.UserId == userId);
            if (bulletin != null)
                throw new BusinessLogicException("Вы уже голосовали");

            bulletin = new SurveyBulletin
            {
                UserId = userId,
                SurveyId = survey.Id,
                Result = options
            };
            DataService.PerThread.SurveyBulletinSet.AddObject(bulletin);
            DataService.PerThread.SaveChanges();

            return survey;
        }