public async Task SendTranscriptRequestAsync(int transcriptRequestId, string studentId, int transcriptId, int schoolId, string receivingInstitutionCode, string receivingInstitutionName, int modifiedById, string receivingInstitutionEmail = "")
        {
            // Get School Settings
            SchoolSettingModel schoolSettings = await _schoolSettingRepository.GetBySchoolIdAsync(schoolId);

            // License check
            LicenseCheck(schoolSettings);

            // Send the transcript request via API
            await _transcriptProviderAPIService.SendTranscriptRequestAsync(schoolSettings.TranscriptProviderId, transcriptRequestId, studentId, transcriptId, schoolId, receivingInstitutionCode, receivingInstitutionName, receivingInstitutionEmail);

            // Update the transcript request history
            await _transcriptRequestRepository.AppendHistoryAsync(transcriptRequestId, TranscriptRequestStatus.Submitted, modifiedById);
        }
예제 #2
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());
        }