Пример #1
0
        public async Task <IActionResult> SendTranscriptRequest(int id, [FromBody] TranscriptSubmitRequestModel submitData)
        {
            // @TODO: Check if the current user is an educator and has permission to view Transcripts => THERE IS ALREADY A CHECK IN FE, THIS IS NECESSARY ONLY TO PROTECT THE API FROM PEOPLE USING SOFTWARE LIKE POSTMAN
            var userAccountId = GetClaim <int>(CcClaimType.UserAccountId);

            var sendTranscriptInfos = await _transcriptRequestRepository.GetSendTranscriptByTranscriptRequestIdAsync(id);

            if (!await _transcriptRequestService.IsSendTranscriptRequestInputValidAsync(sendTranscriptInfos, submitData))
            {
                return(BadRequest());
            }

            switch (submitData.TranscriptRequestType)
            {
            case TranscriptRequestType.Mail:
                var dateSentByMailUtc = await _transcriptRequestService.GetDateSentByMailUtcAsync(sendTranscriptInfos.TranscriptRequestId, submitData.DateSentByMail ?? DateTime.Now, submitData.SkipValidationForDateSentByMail);

                await _transcriptRequestService.SubmitOutOfNetworkAsync(id, TranscriptRequestType.Mail, dateSentByMailUtc : dateSentByMailUtc);

                await _transcriptRequestRepository.AppendHistoryAsync(id, TranscriptRequestStatus.Submitted, userAccountId);

                break;

            case TranscriptRequestType.Email:
                await _transcriptProviderService.SendTranscriptRequestAsync(sendTranscriptInfos.TranscriptRequestId, sendTranscriptInfos.StudentId, sendTranscriptInfos.TranscriptId, sendTranscriptInfos.SchoolId, sendTranscriptInfos.ReceivingInstitutionCode, sendTranscriptInfos.ReceivingInstitutionName, userAccountId, submitData?.ReceivingInstitutionEmail);

                await _transcriptRequestService.SubmitOutOfNetworkAsync(id, TranscriptRequestType.Email, receivingInstitutionEmail : submitData.ReceivingInstitutionEmail);

                break;

            default:
                await _transcriptProviderService.SendTranscriptRequestAsync(sendTranscriptInfos.TranscriptRequestId, sendTranscriptInfos.StudentId, sendTranscriptInfos.TranscriptId, sendTranscriptInfos.SchoolId, sendTranscriptInfos.ReceivingInstitutionCode, sendTranscriptInfos.ReceivingInstitutionName, userAccountId);

                break;
            }
            return(Ok());
        }
Пример #2
0
        public async Task TranscriptRequest_SendForInactiveSchool_ShouldThrowUnlicensedSchoolException()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel();

            schoolSettings.SchoolSettingId     = 1;
            schoolSettings.SchoolId            = 12345;
            schoolSettings.IsTranscriptEnabled = false;

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));
            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.SendTranscriptRequestAsync(55, "12345", 1, 12345, "45784", "NCAA", 1, "");

            // Assert (ExpectedException) -> See the applied ExpectedException attribute to the test's method
        }
Пример #3
0
        public async Task TranscriptRequest_Send_Success()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel();

            schoolSettings.SchoolSettingId     = 1;
            schoolSettings.SchoolId            = xello_test_account_school_id;
            schoolSettings.IsTranscriptEnabled = true;

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));
            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.SendTranscriptRequestAsync(55, "12345", 1, xello_test_account_school_id, "45784", "NCAA", 1);

            // Assert (ran the underlying API call)
            _mockTranscriptProviderAPIService.Verify(m => m.SendTranscriptRequestAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), ""), Times.Once());

            // Assert (appended to transcript request history)
            _mockTranscriptRequestRepository.Verify(m => m.AppendHistoryAsync(It.IsAny <int>(), TranscriptRequestStatus.Submitted, It.IsAny <int>()));
        }