public async Task <ActionResult> AddQuestionToQuestionnaire(string questionContent, int questionnaireId, string answer1, int val1, string answer2, int val2, string answer3, int val3, string answer4, int val4, string answer5, int val5) { if (string.IsNullOrEmpty(questionContent) || string.IsNullOrEmpty(answer1) || val1 == 0 || string.IsNullOrEmpty(answer2) || val2 == 0 || string.IsNullOrEmpty(answer3) || val3 == 0 || string.IsNullOrEmpty(answer4) || val4 == 0 || string.IsNullOrEmpty(answer5) || val5 == 0) { return(RedirectToAction("ErrorInfo", new { id = questionnaireId })); } var newQuestion = new Question { Contents = questionContent, QuestionnaireId = questionnaireId }; await _questionRepo.Create(newQuestion); await _answerRepo.Create(new Answer { Content = answer1, Value = val1, QuestionId = newQuestion.Id }); await _answerRepo.Create(new Answer { Content = answer2, Value = val2, QuestionId = newQuestion.Id }); await _answerRepo.Create(new Answer { Content = answer3, Value = val3, QuestionId = newQuestion.Id }); await _answerRepo.Create(new Answer { Content = answer4, Value = val4, QuestionId = newQuestion.Id }); await _answerRepo.Create(new Answer { Content = answer5, Value = val5, QuestionId = newQuestion.Id }); return(RedirectToAction("ManageQuestions", new{ id = questionnaireId })); }
public int Create(CreateAnswerRequestModel model) { return(_repo.Create(_mapper.Map <Answer>(model))); }