Exemple #1
0
        public async Task <Unit> Handle(InvitationCheckRequest message, CancellationToken cancellationToken)
        {
            var contactInvitation = await _contactRepository.GetContactInvitation(message.ContactId);

            if (contactInvitation is null || contactInvitation.IsAccountCreated)
            {
                return(Unit.Value);
            }

            var acceptedContact = await _contactQueryRepository.GetContactById(contactInvitation.InviteeContactId);

            var invitingContact = await _contactQueryRepository.GetContactById(contactInvitation.InvitorContactId);

            var organisation = await _organisationQueryRepository.Get(contactInvitation.OrganisationId);

            var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate("EPAOLoginAccountCreated");

            await _mediator.Send(new SendEmailRequest(invitingContact.Email, emailTemplate, new
            {
                Contact = invitingContact.GivenNames,
                ContactName = acceptedContact.DisplayName,
                OrganisationName = organisation.EndPointAssessorName,
                ServiceTeam = "Apprenticeship assessment service team"
            }), cancellationToken);

            await _contactRepository.SetInvitationAccepted(contactInvitation);

            return(Unit.Value);
        }
        public async Task <List <ContactResponse> > Handle(UpdateEpaOrganisationPrimaryContactRequest request, CancellationToken cancellationToken)
        {
            var organisation = await _mediator.Send(new GetAssessmentOrganisationRequest { OrganisationId = request.OrganisationId });

            var success = await _mediator.Send(new AssociateEpaOrganisationWithEpaContactRequest
            {
                ContactId            = request.PrimaryContactId,
                OrganisationId       = organisation.OrganisationId,
                ContactStatus        = ContactStatus.Live,
                MakePrimaryContact   = true,
                AddDefaultRoles      = false,
                AddDefaultPrivileges = false
            });

            if (success)
            {
                var primaryContact = await _contactQueryRepository.GetContactById(request.PrimaryContactId);

                var updatedBy = request.UpdatedBy.HasValue
                    ? await _contactQueryRepository.GetContactById(request.UpdatedBy.Value)
                    : null;

                try
                {
                    var primaryContactaAmendedEmailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.EPAOPrimaryContactAmended);

                    if (primaryContactaAmendedEmailTemplate != null)
                    {
                        _logger.LogInformation($"Sending email to notify updated primary contact {primaryContact.Username} for organisation {organisation.Name}");

                        await _mediator.Send(new SendEmailRequest(primaryContact.Email,
                                                                  primaryContactaAmendedEmailTemplate, new
                        {
                            Contact = primaryContact.GivenNames,
                            ServiceName = "Apprenticeship assessment service",
                            Organisation = organisation.Name,
                            ServiceTeam = "Apprenticeship assessment services team",
                            Editor = updatedBy?.DisplayName ?? "EFSA Staff"
                        }), cancellationToken);
                    }
                }
                catch (Exception)
                {
                    _logger.LogInformation($"Unable to send email to notify updated primary contact {primaryContact.Username} for organisation {organisation.Name}");
                }

                return(await _mediator.Send(new SendOrganisationDetailsAmendedEmailRequest
                {
                    OrganisationId = request.OrganisationId,
                    PropertyChanged = "Contact name",
                    ValueAdded = primaryContact.DisplayName,
                    Editor = updatedBy?.DisplayName ?? "ESFA Staff"
                }));
            }

            return(null);
        }
Exemple #3
0
        public async Task <Unit> Handle(RequestForPrivilegeRequest message, CancellationToken cancellationToken)
        {
            var privilege = (await _contactQueryRepository.GetAllPrivileges()).Single(p => p.Id == message.PrivilegeId);

            var requestingContact = await _contactQueryRepository.GetContactById(message.ContactId);

            var organisation = await _organisationQueryRepository.GetOrganisationByContactId(message.ContactId);

            var contactsWithUserManagementPrivilege = (await _contactQueryRepository.GetAllContactsIncludePrivileges(organisation.EndPointAssessorOrganisationId))
                                                      .Where(c => c.ContactsPrivileges.Any(cp => cp.Privilege.Key == Privileges.ManageUsers &&
                                                                                           cp.Contact.Status == ContactStatus.Live)).ToList();

            if (RequestingUserHasUserManagementPrivilege(contactsWithUserManagementPrivilege, requestingContact))
            {
                await _contactRepository.AddPrivilege(requestingContact.Id, message.PrivilegeId);
            }
            else
            {
                var emailTemplate = await _mediator.Send(new GetEmailTemplateRequest { TemplateName = "EPAOPermissionsRequested" }, cancellationToken);

                contactsWithUserManagementPrivilege.ForEach(async contact =>
                {
                    await _mediator.Send(new SendEmailRequest(contact.Email, emailTemplate, new
                    {
                        ServiceName = "Apprenticeship assessment service",
                        Contact     = contact.DisplayName,
                        Username    = requestingContact.DisplayName,
                        Permission  = privilege.UserPrivilege,
                        ServiceTeam = "Apprenticeship assessment service team",
                        LoginLink   = _config.ServiceLink
                    }));
                });
            }
            return(Unit.Value);
        }
Exemple #4
0
        public async Task <Unit> Handle(RejectContactRequest message, CancellationToken cancellationToken)
        {
            const string epaoUserReject = "EPAOUserApproveReject";

            var contact = await _contactQueryRepository.GetContactById(message.ContactId);

            var organisation = await _organisationQueryRepository.Get(contact.OrganisationId.Value);

            await _contactRepository.UpdateStatus(message.ContactId, ContactStatus.New);

            await _contactRepository.UpdateOrganisationId(message.ContactId, null);

            var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(epaoUserReject);

            await _mediator.Send(new SendEmailRequest(contact.Email,
                                                      emailTemplate, new
            {
                Contact = $"{contact.DisplayName}",
                ServiceName = "Apprenticeship assessment service",
                Organisation = organisation.EndPointAssessorName,
                ServiceTeam = "Apprenticeship assessment services team"
            }), cancellationToken);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(ApproveContactRequest message, CancellationToken cancellationToken)
        {
            const string epaoApproveConfirmTemplate = "EPAOUserApproveConfirm";

            var contact = await _contactQueryRepository.GetContactById(message.ContactId);

            var organisation = await _organisationQueryRepository.Get(contact.OrganisationId.Value);

            await _contactRepository.UpdateContactWithOrganisationData(new UpdateContactWithOrgAndStausRequest(message.ContactId.ToString(),
                                                                                                               organisation.Id.ToString(), organisation.EndPointAssessorOrganisationId, ContactStatus.Live));

            var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(epaoApproveConfirmTemplate);

            await _mediator.Send(new SendEmailRequest(contact.Email,
                                                      emailTemplate, new
            {
                Contact = $"{contact.DisplayName}",
                ServiceName = "Apprenticeship assessment service",
                Organisation = organisation.EndPointAssessorName,
                LoginLink = _config.ServiceLink,
                ServiceTeam = "Apprenticeship assessment services team"
            }), cancellationToken);

            return(Unit.Value);
        }
Exemple #6
0
        public async Task <InviteContactToOrganisationResponse> Handle(InviteContactToOrganisationRequest request, CancellationToken cancellationToken)
        {
            var existingContact = await _contactQueryRepository.GetContactFromEmailAddress(request.Email);

            if (existingContact != null)
            {
                return(new InviteContactToOrganisationResponse()
                {
                    Success = false,
                    ErrorMessage = existingContact.OrganisationId == request.OrganisationId
                        ? "This email address is already registered against your organisation. You must use a unique email address."
                        : "This email address is already registered against another organisation. You must use a unique email address."
                });
            }

            var organisation = await _organisationQueryRepository.Get(request.OrganisationId);

            var newContact = await CreateNewContact(request, organisation);

            var inviter = await _contactQueryRepository.GetContactById(request.InvitedByContactId);

            await _signInService.InviteUserToOrganisation(request.Email, request.GivenName, request.FamilyName, newContact.Id, organisation.EndPointAssessorName, inviter.DisplayName);

            await _contactRepository.AddContactInvitation(request.InvitedByContactId, newContact.Id, organisation.Id);

            return(new InviteContactToOrganisationResponse {
                Success = true, ContactId = newContact.Id
            });
        }
        private async Task NotifyContact(Guid id, Guid submittedBy, string standardWithReference, CancellationToken cancellationToken)
        {
            var contactToNotify = await _contactQueryRepository.GetContactById(submittedBy);

            var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.EPAOCancelApplication);

            await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                      new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, StandardWithReference = standardWithReference }), cancellationToken);
        }
Exemple #8
0
        public async Task <Unit> Handle(UpdateSignInIdRequest request, CancellationToken cancellationToken)
        {
            var existingContact = await _contactQueryRepository.GetContactById(request.ContactId);

            await UpdateContactStatusToLive(existingContact);

            await _contactRepository.UpdateSignInId(existingContact.Id, request.SignInId);

            return(Unit.Value);
        }
        private async Task NotifyContact(Guid applicationId, int sequenceNo, CancellationToken cancellationToken)
        {
            var application = await _applyRepository.GetApplication(applicationId);

            if (application != null)
            {
                var loginLink = $"{_config.ServiceLink}/Account/SignIn";

                if (sequenceNo == 1)
                {
                    var lastInitSubmission = application.ApplyData?.Apply.InitSubmissions.OrderByDescending(sub => sub.SubmittedAt).FirstOrDefault();

                    if (lastInitSubmission != null)
                    {
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastInitSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.APPLY_EPAO_UPDATE);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, LoginLink = loginLink }), cancellationToken);
                    }
                }
                else if (sequenceNo == 2)
                {
                    var standardName           = application.ApplyData?.Apply.StandardName ?? string.Empty;
                    var lastStandardSubmission = application.ApplyData?.Apply.StandardSubmissions.OrderByDescending(sub => sub.SubmittedAt).FirstOrDefault();

                    if (lastStandardSubmission != null)
                    {
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastStandardSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.APPLY_EPAO_RESPONSE);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, standard = standardName, LoginLink = loginLink }), cancellationToken);
                    }
                }
            }
        }
        public async Task <Guid> Handle(CreateApplicationRequest request, CancellationToken cancellationToken)
        {
            var org = await _organisationQueryRepository.Get(request.OrganisationId);

            var orgTypes = await _registerQueryRepository.GetOrganisationTypes();

            var creatingContact = await _contactQueryRepository.GetContactById(request.CreatingContactId);

            if (org != null && orgTypes != null && creatingContact != null)
            {
                var orgType = orgTypes.FirstOrDefault(x => x.Id == org.OrganisationTypeId);

                var sequences = request.ApplySequences;
                DisableSequencesAndSectionsAsAppropriate(sequences, org, orgType);
                MakeLowerSequenceActive(sequences);

                var applyData = new ApplyData
                {
                    Sequences = sequences,
                    Apply     = new ApplyTypes.Apply
                    {
                        ReferenceNumber          = await CreateReferenceNumber(request.ApplicationReferenceFormat),
                        InitSubmissions          = new List <Submission>(),
                        InitSubmissionsCount     = 0,
                        StandardSubmissions      = new List <Submission>(),
                        StandardSubmissionsCount = 0
                    }
                };

                var application = new Domain.Entities.Apply
                {
                    ApplyData             = applyData,
                    ApplicationId         = request.QnaApplicationId,
                    ApplicationStatus     = ApplicationStatus.InProgress,
                    ReviewStatus          = ApplicationReviewStatus.Draft,
                    FinancialReviewStatus = IsFinancialExempt(org.OrganisationData?.FHADetails, orgType) ? FinancialReviewStatus.Exempt : FinancialReviewStatus.Required,
                    OrganisationId        = org.Id,
                    CreatedBy             = creatingContact.Id.ToString(),
                    CreatedAt             = DateTime.UtcNow
                };

                return(await _applyRepository.CreateApplication(application));
            }

            return(Guid.Empty);
        }
        public async Task <IActionResult> GetContactById(string id)
        {
            Contact contact = null;

            _logger.LogInformation($" Get Request using user id = {id}");
            try
            {
                var guidId = Guid.Parse(id);
                contact = await _contactQueryRepository.GetContactById(guidId);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Failed to retrieve contact with id : {id}");
            }

            if (contact == null)
            {
                throw new ResourceNotFoundException();
            }

            return(Ok(Mapper.Map <ContactResponse>(contact)));
        }
Exemple #12
0
        public async Task <List <ContactResponse> > Handle(UpdateEpaOrganisationEmailRequest request, CancellationToken cancellationToken)
        {
            var organisation = await _mediator.Send(new GetAssessmentOrganisationRequest { OrganisationId = request.OrganisationId });

            var updateEpaOrganisationRequest = Mapper.Map <UpdateEpaOrganisationRequest>(organisation);

            updateEpaOrganisationRequest.Email = request.Email;

            await _mediator.Send(updateEpaOrganisationRequest);

            var updatedBy = request.UpdatedBy.HasValue
                ? await _contactQueryRepository.GetContactById(request.UpdatedBy.Value)
                : null;

            return(await _mediator.Send(new SendOrganisationDetailsAmendedEmailRequest
            {
                OrganisationId = request.OrganisationId,
                PropertyChanged = "Email address",
                ValueAdded = request.Email,
                Editor = updatedBy?.DisplayName ?? "EFSA Staff"
            }));
        }
        public async Task <bool> Handle(SubmitApplicationSequenceRequest request, CancellationToken cancellationToken)
        {
            // CanSubmitApplication was migrated over from Apply Service. If this causes issues then remove it
            if (await _applyRepository.CanSubmitApplication(request.ApplicationId))
            {
                var application = await _applyRepository.GetApply(request.ApplicationId);

                var submittingContact = await _contactQueryRepository.GetContactById(request.SubmittingContactId);

                if (application?.ApplyData != null && submittingContact != null)
                {
                    if (application.ApplyData.Apply == null)
                    {
                        application.ApplyData.Apply = new ApplyTypes.Apply();
                    }

                    if (string.IsNullOrWhiteSpace(application.ApplyData.Apply.ReferenceNumber))
                    {
                        application.ApplyData.Apply.ReferenceNumber = await CreateReferenceNumber(request.ApplicationReferenceFormat);
                    }

                    AddSubmissionInfoToApplyData(application.ApplyData, request.SequenceNo, submittingContact);
                    UpdateSequenceAndSectionStatus(application.ApplyData, request.SequenceNo, request.RequestedFeedbackAnswered);
                    UpdateApplicationAndReviewStatus(application, request.SequenceNo);

                    application.UpdatedBy = submittingContact.Id.ToString();
                    application.UpdatedAt = DateTime.UtcNow;

                    await _applyRepository.SubmitApplicationSequence(application);

                    await NotifyContact(submittingContact, application.ApplyData, request.SequenceNo, cancellationToken);

                    return(true);
                }
            }

            return(false);
        }
Exemple #14
0
        public async Task <List <ContactResponse> > Handle(UpdateEpaOrganisationAddressRequest request, CancellationToken cancellationToken)
        {
            var organisation = await _mediator.Send(new GetAssessmentOrganisationRequest { OrganisationId = request.OrganisationId });

            var updateEpaOrganisationRequest = Mapper.Map <UpdateEpaOrganisationRequest>(organisation);

            updateEpaOrganisationRequest.Address1 = request.AddressLine1;
            updateEpaOrganisationRequest.Address2 = request.AddressLine2;
            updateEpaOrganisationRequest.Address3 = request.AddressLine3;
            updateEpaOrganisationRequest.Address4 = request.AddressLine4;
            updateEpaOrganisationRequest.Postcode = request.Postcode;

            await _mediator.Send(updateEpaOrganisationRequest);

            var updatedBy = request.UpdatedBy.HasValue
                ? await _contactQueryRepository.GetContactById(request.UpdatedBy.Value)
                : null;

            string valueAdded = string.Join(", ",
                                            (new List <string>
            {
                request.AddressLine1,
                request.AddressLine2,
                request.AddressLine3,
                request.AddressLine4,
                request.Postcode
            })
                                            .Where(p => !string.IsNullOrEmpty(p))
                                            .ToArray());

            return(await _mediator.Send(new SendOrganisationDetailsAmendedEmailRequest
            {
                OrganisationId = request.OrganisationId,
                PropertyChanged = "Contact address",
                ValueAdded = valueAdded,
                Editor = updatedBy?.DisplayName ?? "EFSA Staff"
            }));
        }
        public async Task <OrganisationStandardVersion> Handle(OrganisationStandardVersionOptInRequest request, CancellationToken cancellationToken)
        {
            try
            {
                // Remove out of unit of work due to crossover betwen EF, Dapper and UnitOfWorkTransaction Conflict
                // It's also a Read so has no impact in that case.
                var submittingContact = await _contactQueryRepository.GetContactById(request.SubmittingContactId);

                _unitOfWork.Begin();

                var orgStandard = await _repository.GetOrganisationStandardByOrganisationIdAndStandardReference(request.EndPointAssessorOrganisationId, request.StandardReference);

                var entity = new Domain.Entities.OrganisationStandardVersion
                {
                    StandardUId            = request.StandardUId,
                    Version                = request.Version,
                    OrganisationStandardId = orgStandard.Id,
                    EffectiveFrom          = request.EffectiveFrom,
                    EffectiveTo            = request.EffectiveTo,
                    DateVersionApproved    = request.DateVersionApproved,
                    Comments               = request.Comments,
                    Status = request.Status
                };

                var existingVersion = await _repository.GetOrganisationStandardVersionByOrganisationStandardIdAndVersion(orgStandard.Id, request.Version);

                if (request.OptInFollowingWithdrawal && existingVersion != null)
                {
                    await _repository.UpdateOrganisationStandardVersion(entity);
                }
                else if (existingVersion != null)
                {
                    throw new InvalidOperationException("OrganisationStandardVersion already exists");
                }
                else
                {
                    await _repository.CreateOrganisationStandardVersion(entity);
                }

                var orgStandardVersion = (OrganisationStandardVersion)entity;

                var application = await _applyRepository.GetApply(request.ApplicationId);

                var standard = await _standardRepository.GetStandardVersionByStandardUId(request.StandardUId);

                application.ApplicationStatus                 = ApplicationStatus.Approved;
                application.ReviewStatus                      = ApplicationStatus.Approved;
                application.StandardReference                 = request.StandardReference;
                application.StandardCode                      = standard.LarsCode;
                application.ApplyData.Apply.StandardCode      = standard.LarsCode;
                application.ApplyData.Apply.StandardReference = request.StandardReference;
                application.ApplyData.Apply.StandardName      = standard.Title;
                application.ApplyData.Apply.Versions          = new List <string>()
                {
                    request.Version
                };
                application.ApplyViaOptIn = true;

                await _applyRepository.SubmitApplicationSequence(application);

                await NotifyContact(submittingContact, application.ApplyData, cancellationToken);

                _unitOfWork.Commit();

                return(orgStandardVersion);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed to opt-in standard version {request.StandardReference} {request.Version} for Organisation {request.EndPointAssessorOrganisationId}");
                _unitOfWork.Rollback();
                throw;
            }
        }
        private async Task NotifyContact(Guid applicationId, int sequenceNo, string returnType, CancellationToken cancellationToken)
        {
            var application = await _applyRepository.GetApply(applicationId);

            if (application != null)
            {
                var loginLink = $"{_config.ServiceLink}/Account/SignIn";

                if (sequenceNo == ApplyConst.ORGANISATION_SEQUENCE_NO)
                {
                    var lastSubmission = application.ApplyData?.Apply.LatestInitSubmission;
                    if (lastSubmission != null)
                    {
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.APPLY_EPAO_UPDATE);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, LoginLink = loginLink }), cancellationToken);
                    }
                }
                else if (sequenceNo == ApplyConst.STANDARD_SEQUENCE_NO)
                {
                    var lastSubmission = application.ApplyData?.Apply.LatestStandardSubmission;
                    if (lastSubmission != null)
                    {
                        var standardName    = application.ApplyData?.Apply.StandardName ?? string.Empty;
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.APPLY_EPAO_RESPONSE);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, standard = standardName, LoginLink = loginLink }), cancellationToken);
                    }
                }
                else if (returnType == "ReturnWithFeedback" &&
                         (sequenceNo == ApplyConst.ORGANISATION_WITHDRAWAL_SEQUENCE_NO ||
                          sequenceNo == ApplyConst.STANDARD_WITHDRAWAL_SEQUENCE_NO))
                {
                    var lastSubmission = sequenceNo == ApplyConst.ORGANISATION_WITHDRAWAL_SEQUENCE_NO
                        ? application.ApplyData?.Apply.LatestOrganisationWithdrawalSubmission
                        : application.ApplyData?.Apply.LatestStandardWithdrawalSubmission;

                    if (lastSubmission != null)
                    {
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.EPAOWithdrawalFeedbackNotification);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new
                        {
                            ServiceName = SERVICE_NAME,
                            ServiceTeam = SERVICE_TEAM,
                            Contact = contactToNotify.DisplayName,
                            LoginLink = loginLink
                        }), cancellationToken);
                    }
                }
                else if (sequenceNo == ApplyConst.ORGANISATION_WITHDRAWAL_SEQUENCE_NO && returnType == "Approve")
                {
                    var lastSubmission = application.ApplyData?.Apply.LatestOrganisationWithdrawalSubmission;
                    if (lastSubmission != null)
                    {
                        var contactToNotify = await _contactQueryRepository.GetContactById(lastSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.EPAORegisterWithdrawalApproval);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, LoginLink = loginLink }), cancellationToken);
                    }
                }
                else if (sequenceNo == ApplyConst.STANDARD_WITHDRAWAL_SEQUENCE_NO && returnType == "Approve")
                {
                    var lastSubmission = application.ApplyData?.Apply.LatestStandardWithdrawalSubmission;
                    if (lastSubmission != null)
                    {
                        var standardName      = application.ApplyData?.Apply.StandardName ?? string.Empty;
                        var standardReferance = application.ApplyData?.Apply.StandardReference ?? string.Empty;
                        var contactToNotify   = await _contactQueryRepository.GetContactById(lastSubmission.SubmittedBy);

                        var emailTemplate = await _eMailTemplateQueryRepository.GetEmailTemplate(EmailTemplateNames.EPAOStandardWithdrawalApproval);

                        await _mediator.Send(new SendEmailRequest(contactToNotify.Email, emailTemplate,
                                                                  new { ServiceName = SERVICE_NAME, ServiceTeam = SERVICE_TEAM, Contact = contactToNotify.DisplayName, StandardName = standardName, StandardReference = standardReferance, LoginLink = loginLink }), cancellationToken);
                    }
                }
            }
        }