public ActionResult CurrentTest(Guid testResultId) { _logger.LogInformation("GET Test/PassTest"); User user = null; if (Get("user") != null) { Guid user_id = Guid.Parse(Get("user")); user = _userRepo.GetUser(user_id); } else { _logger.LogInformation("User is not logged!"); } if (user != null && user.Role == "Student") { var testResult = _testResultRepo.GetTestResult(testResultId); if (testResult != null && testResult.Test != null) { ViewData["TestName"] = testResult.Test.Name; ViewData["TestResultId"] = testResult.Id; ViewData["LoggedIn"] = "true"; return(View(testResult.TaskResults)); } } if (user != null) { _logger.LogInformation("User is not student!"); } else { _logger.LogInformation("User authorised but not exist!"); } ViewData["LoggedIn"] = "false"; return(RedirectToAction("Error")); }
public HttpResponseMessage GetTestResults(int testResultId) { try { var result = _repo.GetTestResult(testResultId); if (result == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "No record found" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = result })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = ex.Message })); } }