// GET: Start Exam
 public ActionResult ViewExam(int?ExamId)
 {
     if (ExamId != null)
     {
         Exam examlist = _examservice.GetById(Convert.ToInt32(ExamId));
         if (examlist != null)
         {
             examresource     = Mapper.Map <Exam, ExamResource>(examlist);
             ViewBag.count    = _examQuestionService.FindBy(i => i.ExamId == ExamId).Count();
             ViewBag.NotFound = false;
             return(View(examresource));
         }
     }
     ViewBag.NotFound = true;
     return(View());
 }
        // GET: Start Exam
        public ActionResult ViewExam(int ExamId)
        {
            var userId = User.Identity.GetUserId();
            var user   = UserManager.FindById(userId);
            int packageId;

            if (user != null)
            {
                packageId = user.PackageId;
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }


            var package = _packageService.GetById(packageId);

            ViewBag.packageId = packageId;

            if (package != null)
            {
                var startDate  = user.StartDate;
                var duration   = package.Duration;
                var expiryDate = startDate.AddMonths(duration);
                if (DateTime.Now < expiryDate)
                {
                    Exam examlist = _examservice.GetById(ExamId);
                    examresource = Mapper.Map <Exam, ExamResource>(examlist);
                }
                else
                {
                    return(RedirectToAction("Index", "Packages"));
                }
            }
            ViewBag.count = _examQuestionService.FindBy(i => i.ExamId == ExamId).Count();
            return(View(examresource));
        }