async public Task<ActionResult> Create(Quiz model, ICollection<QuestionOptionsModel> questions) { try { model.LearningObject_id = LOID; model.created_at = DateTime.UtcNow; model.updated_at = DateTime.UtcNow; int quizId = await _mLearningService.CreateObject<Quiz>(model, q => q.id); foreach (var questionOptions in questions) { Question question = questionOptions.Question; question.Quiz_id = quizId; question.created_at = DateTime.UtcNow; question.updated_at = DateTime.UtcNow; int questionId = await _mLearningService.CreateObject<Question>(question, q => q.id); foreach (var option in questionOptions.Options) { option.created_at = DateTime.UtcNow; option.updated_at = DateTime.UtcNow; option.Question_id = questionId; int optionId = await _mLearningService.CreateObject<QuestionOption>(option, o => o.id); } } /*foreach (var question in model.Questions) { question.Question.Quiz_id = quizId; question.Question.created_at = DateTime.UtcNow; question.Question.updated_at = DateTime.UtcNow; int questionId = await _mLearningService.CreateObject<Question>(question.Question, q => q.id); foreach (var option in question.Options) { option.Question_id = questionId; option.created_at = DateTime.UtcNow; option.updated_at = DateTime.UtcNow; await _mLearningService.CreateObject<QuestionOption>(option, o => o.id); } }*/ // return Json(Url.Action("EditLO", "Publisher", new { lo_id = LOID })); return RedirectToAction("EditLO", "Publisher"); } catch { return View("QuizCreate"); } }
public ActionResult Delete(int quiz_id, Quiz todelete) { try { todelete.id = quiz_id; _mLearningService.DeleteObject<Quiz>(todelete); return RedirectToAction("EditLO", "Publisher", new { lo_id = LOID }); } catch { return View("QuizDelete", todelete); } }