Example #1
0
        public async Task <JsonResult> AddQuestion(string surveyid)
        {
            int order    = surveyQuestionRepository.GetItems().Where(x => x.SurveyId == surveyid).Count();
            var question = await surveyQuestionRepository.Create(new SurveyQuestion { QuestionText = "Новый вопрос", HasOwnAnswer = false, IsRequired = false, SurveyId = surveyid, Type = 0, Order = order });

            return(new JsonResult(new { surveyquestionid = question.Id, text = question.QuestionText }));
        }//Метод не используется
        public async Task <ISurveyQuestion> CreateNewQuestion(Guid surveyId, ISurveyQuestion questionDto)
        {
            try
            {
                var question = Mappings.Mapper.Map <SurveyQuestion>(questionDto);
                question.SurveyId = surveyId;
                question.Id       = Guid.NewGuid();
                var persistedEntity = await _questionRepository.Create(question);

                questionDto.Id = persistedEntity.Id;
                return(questionDto);
            }
            catch (Exception e)
            {
                _logger.Error(e, "SurveyQuestionManagementService.CreateNewQuestion");
                throw;
            }
        }