Пример #1
0
        public async Task <bool> SubmitAnswerToTestResult(AnswerDTO answerDTO)
        {
            var model = await CreateModelFromDTO(answerDTO);

            var testresult = await GetExistingTestResult(answerDTO.TestID, answerDTO.User);

            if (await testResultRepository.GetAsync(testresult?.ID) != null)
            {
                if (IsInTime(testresult.StartTime, testresult.Test.AllowedTakeLength))
                {
                    testresult.Answers.Add(model);
                    return(await testResultRepository.UpdateAsync(testresult));
                }
                else if (!testresult.IsClosed)
                {
                    CorrectTestResult(testresult);
                    return(false); // TODO throw exception
                }
            }

            return(false);
        }
Пример #2
0
 public async Task <TestResult> Get(string uid)
 {
     return(await testResultRepository.GetAsync(uid));
 }