// add question and answers to questionnaire public async Task <Questionnaire> AddQuestionsAsync(int questionnaireId, IEnumerable <Question> questions) { VerifyManagementPermission(); int authId = GetClaimId(ClaimType.UserId); foreach (var question in questions) { question.QuestionnaireId = questionnaireId; var addedQuestion = await _questionRepository.AddSaveAsync(authId, question); foreach (var answer in question.Answers) { answer.QuestionId = addedQuestion.Id; await _answerRepository.AddAsync(authId, answer); } await _answerRepository.SaveAsync(); } return(await _questionnaireRepository.GetByIdAsync(questionnaireId)); }