Beispiel #1
0
 public ActionResult Edit(int id)
 {
     var question = questionService.GetQuestion(id);
     var viewModel = new TrainerQuestionEditViewModel
     {
         Id = question.Id,
         Answer1 = question.Answer1,
         Answer2 = question.Answer2,
         Answer3 = question.Answer3,
         Answer4 = question.Answer4,
         Name = question.Name,
         TrueAnswer = question.Answer,
         Value = question.Value,
         TestId = question.Test.Id,
     };
     return View(viewModel);
 }
Beispiel #2
0
 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);
 }