Exemple #1
0
 // GET: Test
 public ActionResult Index()
 {
     if (Session["username"] != null)
     {
         UsrService      usrService  = new UsrService();
         int             apply_id    = usrService.getApplyIdByUsername(Session["username"].ToString());
         JOB_APPLICATION application = JobApplicationService.findByUsername(Session["username"].ToString());
         ViewBag.Application = application;
         TEST test = TestService.getTestByApplyId(apply_id);
         ViewBag.Test = test;
         //if start time is later than now and end time is ealier than now let the candidate have link to do test
         if (DateTime.Compare(DateTime.Now, test.START_TIME) > 0 && DateTime.Compare(DateTime.Now, test.END_TIME) < 0)
         {
             ViewBag.link = TestService.getIndexByApplyId(apply_id);
         }
         //timer
         TimeSpan timeLeft = test.END_TIME - test.START_TIME;
         ViewBag.TimeLeft = timeLeft;
         return(View());
     }
     return(RedirectToAction("Login", "Home"));
 }