コード例 #1
0
 public ActionResult TestPass(int id)
 {
     TestEntity test = TestService.GetTestByKey(id);
     TestSubmitViewModel testSubmit = new TestSubmitViewModel
     {
         Test = test.ToViewModel(),
         User = CurrentUser,
         Answers = new List<OptionViewModel>(),
         DateTimeStart = DateTime.Now
     };
     if (testSubmit.MoveToNextQuestion())
     {
         Session["testSubmit"] = testSubmit;
         return View(testSubmit.CurrentQuestion);
     }
     return Redirect("ErrorPage");
 }
コード例 #2
0
ファイル: ViewMapper.cs プロジェクト: eugeni96/TestingSystem
 public static TestSubmitViewModel ToViewModel(this TestCompletedEntity testCompletedEntity)
 {
     TestSubmitViewModel testSubmitViewModel = new TestSubmitViewModel()
     {
         Answers = new List<OptionViewModel>(),
         DateTimeFinish = testCompletedEntity.DateTimeFinish,
         DateTimeStart = testCompletedEntity.DateTimeStart,
         IsFinished = testCompletedEntity.IsFinished,
         Test = testCompletedEntity.Test.ToViewModel(),
         User = testCompletedEntity.User
     };
     foreach (OptionEntity answer in testCompletedEntity.Answers)
     {
         testSubmitViewModel.Answers.Add(answer.ToViewModel());
     }
     return testSubmitViewModel;
 }