示例#1
0
        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);
        }
示例#2
0
 /// <summary>
 /// Edits question
 /// </summary>
 /// <param name="question">The question to be edited</param>
 public void EditQuestion(Question question)
 {
     questionRepo.Update(question);
     questionRepo.Save();
 }
示例#3
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);
 }
示例#4
0
 /// <summary>
 /// Creates question
 /// </summary>
 /// <param name="question">The question to be created</param>
 public void CreateQuestion(Question question)
 {
     questionRepo.Add(question);
     questionRepo.Save();
 }