public ActionResult PassingTest(PassingTestViewModel model) { bool isSuccess = false; var test = testService.GetById(model.Id); int userId = userService.GetOneByPredicate(u => u.UserName == User.Identity.Name).Id; var testResults = testService.CheckAnswers(model.Id, model.Results); var runtime = (DateTime.UtcNow - model.StartTest); if (testResultService.CheckPercentAnswers(testResults, test.MinToSuccess) && testResultService.CheckTime(test.TimeLimit, runtime)) { isSuccess = true; } var bllTestResult = new BllTestResult { TestId = model.Id, UserId = userId, Runtime = runtime, DateComplete = DateTime.Now, IsSuccess = isSuccess, Results = testResults.ToList() }; testResultService.Create(bllTestResult); var mvcTestResult = bllTestResult.ToMvcStatistics(); mvcTestResult.TimeLimit = test.TimeLimit; mvcTestResult.MinToSuccess = test.MinToSuccess; mvcTestResult.PercentCorrectAnswers = testResultService.GetPercentGoodAnswers(testResults); if (Request.IsAjaxRequest()) { return(PartialView("_Statistics", mvcTestResult)); } return(View("_Statistics", mvcTestResult)); }