public ActionResult NewTest(TestViewModel test)
 {
     if (!ModelState.IsValid)
     {
         ModelState.AddModelError("", "Invalid data");
         return View(test);
     }
     TestEntity e = new TestEntity()
     {
         Name = test.Name,
         Description = test.Description,
         AllowedTime = test.AllowedTime,
         Anonymous = test.Anonymous,
         AuthorId = userService.GetByLogin(SessionPersister.Username).Id,
         CreationDate = DateTime.Now,
         GlobalAvailability = test.GlobalAvailability,
         Interview = test.Interview,
         QuestionCount = 0
     };
     testService.CreateTest(e);
     return RedirectToAction("Index");
 }
 private bool IsTestReady(TestViewModel test)
 {
     TestEntity t = testService.GetById(test.Id);
     if (t.QuestionCount == 0)
         return false;
     IEnumerable<QuestionEntity> questions = questionService.GetAllTestQuestions(test.ToBllTest());
     foreach(QuestionEntity q in questions)
     {
         if(!IsQuestionReady(q.ToMvcQuestion()))
         {
             return false;
         }
     }
     return true;
 }