public async Task <IActionResult> AddQuiz(QuizDto quiz) { var questionToAdd = new QuizQuestion(); questionToAdd.Question = quiz.Question; _repo.Add(questionToAdd); if (await _repo.SaveAll()) { foreach (var option in quiz.Options) { var optionToAdd = new Option(); optionToAdd.Answer = option.Answer; optionToAdd.IsCorrect = option.isCorrect; optionToAdd.Question = await _repo.GetQuizQuestionAsync(questionToAdd.Id); _repo.Add(optionToAdd); await _repo.SaveAll(); } return(Ok(quiz)); } throw new Exception("Question failed to add"); }