public async Task SetCurrentTestResults(int?id)
        {
            try
            {
                // I. Clear controller properties for processing a test period.
                //TestPeriod = 0;
                //StartTestTime = null;

                // II. Check.
                OperationDetails operationDetails;
                string           currentUserId = System.Web.HttpContext.Current.User.Identity.GetUserId();
                if (currentUserId == null || AllAnswers.Count == 0 || UserAnswers.Count == 0)
                {
                    return;
                }

                // III.Get the test result.
                operationDetails = PLRepository.CalculateTestResults(AllAnswers, UserAnswers, TestQuetions, out TestResultViewModel testResult);
                if (!operationDetails.Succedeed)
                {
                    return;
                }
                // Is the test passed?
                int       firstQuestionId = AllAnswers.FirstOrDefault().Key;
                CourseDTO courseDTO       = (await QuestionService.GetAsync(firstQuestionId)).Topic.Course;
                testResult.IsPassedTest = testResult.Result > testResult.MaxScore * courseDTO.PassingScore / 100;

                // IV. Write the test results to DB.
                operationDetails = await SaveCurrentTestResults(id, currentUserId, testResult);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        // Get test results.
        public async Task <ActionResult> GetCurrentTestResults(int?id)
        {
            try
            {
                // I. Clear controller properties for processing a test period.
                TestPeriod    = 0;
                StartTestTime = null;

                // II. Check.
                if (AllAnswers.Count == 0 || UserAnswers.Count == 0)
                {
                    return(RedirectToAction("Index"));
                }

                // III.Get the test result.
                OperationDetails operationDetails = PLRepository.CalculateTestResults(AllAnswers, UserAnswers, TestQuetions, out TestResultViewModel testResult);
                if (!operationDetails.Succedeed)
                {
                    return(View("Report", operationDetails));
                }
                // Is the test passed?
                int       firstQuestionId = AllAnswers.FirstOrDefault().Key;
                CourseDTO courseDTO       = (await QuestionService.GetAsync(firstQuestionId)).Topic.Course;
                testResult.IsPassedTest = testResult.Result > testResult.MaxScore * courseDTO.PassingScore / 100;
                // Set ViewBag property for a View.
                ViewBag.CourseName = courseDTO.CourseTitle;

                // IV.Set testResult properies (Result, MaxScore and TestResultDetails).
                testResult.Result   = testResult.Result * 1000 / testResult.MaxScore;
                testResult.MaxScore = 1000;
                foreach (var item in testResult.TestResultDetails)
                {
                    item.Topic    = (await QuestionService.GetAsync(item.QuestionId)).Topic.TopicTitle;
                    item.Question = (await QuestionService.GetAsync(item.QuestionId)).QuestionText;
                }

                // V.
                return(View(testResult));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }