예제 #1
0
        public async Task <IActionResult> CreateTestResult(int doctorId, int patientId, int testId, QuestionsAnswersViewModel questionsAnswers)
        {
            if (doctorId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized("Пользователь не авторизован"));
            }

            var test = await _testService.GetTestAsync(testId);

            if (test == null)
            {
                BadRequest("Теста с указаным идентификаторм не существет");
            }

            var testResultInPoints = _testService.GetTestResultInPoints(questionsAnswers, test.Name);

            var patientTestResult = await _testService.CreateAndGetPatientTestResultAsnyc(doctorId, patientId, testId, testResultInPoints, questionsAnswers);

            return(Ok(patientTestResult));
        }