public ActionResult Create(TrainerQuestionCreateViewModel viewModel) { if (ModelState.IsValid) { var question = new Question { Answer = viewModel.TrueAnswer, Answer1 = viewModel.Answer1, Answer2 = viewModel.Answer2, Answer3 = viewModel.Answer3, Answer4 = viewModel.Answer4, Name = viewModel.Name, TestId = viewModel.TestId, Value = viewModel.Value, }; questionService.CreateQuestion(question); return Redirect("/trainer/test/details/" + viewModel.TestId); } return View(viewModel); }
/// <summary> /// Edits question /// </summary> /// <param name="question">The question to be edited</param> public void EditQuestion(Question question) { questionRepo.Update(question); questionRepo.Save(); }
public ActionResult Edit(int id, TrainerQuestionEditViewModel viewModel) { if (ModelState.IsValid) { var question = new Question { Id = viewModel.Id, Answer = viewModel.TrueAnswer, Answer1 = viewModel.Answer1, Answer2 = viewModel.Answer2, Answer3 = viewModel.Answer3, Answer4 = viewModel.Answer4, Name = viewModel.Name, Value = viewModel.Value, TestId = viewModel.TestId, }; questionService.EditQuestion(question); return Redirect("/trainer/test/"); } return View(viewModel); }
/// <summary> /// Creates question /// </summary> /// <param name="question">The question to be created</param> public void CreateQuestion(Question question) { questionRepo.Add(question); questionRepo.Save(); }