コード例 #1
0
 public void Post([FromBody] TestResultParam testResult)
 {
     _testResultRepository.AddTestResult(new TestResult {
         FileName     = testResult.FileName,
         CreatedOn    = DateTime.Now,
         TestRunIndex = testResult.TestRunIndex,
         TestType     = testResult.TestType,
         Resolution   = testResult.Resolution,
         Browser      = testResult.Browser,
         ComputerType = testResult.ComputerType,
         TestTime     = testResult.TestTime,
         FileDuration = testResult.FileDuration
     });
 }
コード例 #2
0
        public async Task <HttpResponseMessage> AddTestResult(IEnumerable <TestResultVM> model)
        {
            try
            {
                var response = await _repo.AddTestResult(model);

                if (response == 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "No record found" }));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = response }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = ex.Message }));
            }
        }
コード例 #3
0
        public HttpResponseMessage AddTestResult(TestResultVM model)
        {
            try
            {
                var response = _repo.AddTestResult(model);

                if (response == false)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "No record found" }));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = response }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = ex.Message }));
            }
        }
コード例 #4
0
        public ActionResult PassTest(Guid testId)
        {
            _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 test = _testRepo.GetTest(testId);
                if (test != null)
                {
                    var testResult = new TestResult(user, test);
                    _testResultRepo.AddTestResult(testResult);
                    foreach (var task in test.Tasks)
                    {
                        var taskResult = new TaskResult(testResult, task);
                        _taskResultRepo.AddTaskResult(taskResult);
                        task.Options.ForEach(x => _optionResultRepo.AddOptionResult(new OptionResult(taskResult, x, false)));
                    }
                    _userRepo.SetCurrentTest(user.Id, testResult.Id);
                    return(RedirectToAction("CurrentTest", new { testResultId = testResult.Id }));
                }
            }
            if (user != null)
            {
                _logger.LogInformation("User is not student!");
            }
            else
            {
                _logger.LogInformation("User authorised but not exist!");
            }
            return(RedirectToAction("Error"));
        }