Пример #1
0
 public ActionResult Create()
 {
     if (IsCurrentUserInRole("Moderator"))
     {
         TestViewModel test = new TestViewModel();
         CreateTestViewModel createEditTestViewModel = new CreateTestViewModel()
         {
             Test = test,
             AllQuestions = QuestionService.GetAll().Select(question => new QuestionPickViewModel()
             {
                 Id = question.Id,
                 Text = question.Text
             }).ToList()
         };
         return View(createEditTestViewModel);
     }
     return RedirectToNotFoundPage;
 }
Пример #2
0
 public static TestViewModel ToViewModel(this TestEntity testEntity)
 {
     TestViewModel testViewModel = new TestViewModel()
     {
         Id = testEntity.Id,
         Name = testEntity.Name,
         Questions = new List<QuestionViewModel>()
     };
     foreach (QuestionEntity questionEntity in testEntity.Questions)
     {
         testViewModel.Questions.Add(questionEntity.ToViewModel());
     }
     return testViewModel;
 }