public async Task <bool> UpdateExistingQuestion(Guid id, ISurveyQuestion questionDto)
        {
            try
            {
                var question = await _questionRepository.Get(id);

                if (question == null)
                {
                    return(false);
                }
                Mappings.Mapper.Map <ISurveyQuestion, SurveyQuestion>(questionDto, question);

                await _questionRepository.Update(question);

                return(true);
            }
            catch (Exception e)
            {
                _logger.Error(e, "SurveyQuestionManagementService.UpdateExistingQuestion");
                throw;
            }
        }
Пример #2
0
        }//Метод не используется

        public async Task <JsonResult> RemoveQuestion(string surveyquestionid)
        {
            var question = surveyQuestionRepository.GetItems().Include(x => x.Options).FirstOrDefault(x => x.Id == surveyquestionid);
            await surveyQuestionRepository.Delete(question);

            var options = question.Options;

            foreach (var option in options)
            {
                await optionRepository.Delete(option);
            }

            var questions = surveyQuestionRepository.GetItems().Where(x => x.SurveyId == question.SurveyId && x.Order > question.Order).ToList();

            foreach (var curquestion in questions)
            {
                curquestion.Order--;
                await surveyQuestionRepository.Update(curquestion);
            }

            return(new JsonResult(surveyquestionid));
        }//Метод не используется