Example #1
0
        public ActionResult Test(int IdTest)
        {
            var   user = (User)Session[Common.USER_SESSION];
            ETest test = TestContext.SearchTestOfUser(IdTest, user.Id);

            if (test == null)
            {
                return(null);
            }
            // new Test
            if (test.Status.ToUpper() == "NotStart".ToUpper())
            {
                int count = UserResultContext.AddTest(test.Id);
                if (count == 0)
                {
                    return(RedirectToAction("Index"));
                }
            }
            else if (test.Status == Entity.baseEmun.StaticTest.Finish.ToString())
            {
                return(RedirectToAction("Index"));
            }
            else if (test.TimeStart != null)
            {
                DateTime timeNow = DateTime.Now;
                if (timeNow - test.TimeStart > test.Time)
                {
                    BLTest.CheckIsFinish(test.Id);
                    return(RedirectToAction("Index"));
                }
                test.Time = test.Time - (TimeSpan)(timeNow - test.TimeStart);
            }
            ViewData["user"] = user;
            ViewData["Test"] = test;
            return(View());
        }
Example #2
0
 public ActionResult FinishTest(int IdTest)
 {
     TestContext.UpdateStatus(IdTest);
     BLTest.CheckIsFinish(IdTest);
     return(RedirectToAction("Index"));
 }