Esempio n. 1
0
 public Task PublishDataLockTriageApproved(IApprenticeshipEvent apprenticeshipEvent)
 {
     return(PublishWithLog <DataLockTriageApprovedEvent>(ApprenticePreChecks.NotRequired, apprenticeshipEvent?.Apprenticeship, ev =>
     {
         ev.ApprenticeshipId = apprenticeshipEvent.Apprenticeship.Id;
         ev.ApprovedOn = _currentDateTime.Now;
         ev.PriceEpisodes = GetPriceEpisodes(apprenticeshipEvent.Apprenticeship);
         ev.TrainingType = (CommitmentsV2.Types.ProgrammeType)apprenticeshipEvent.Apprenticeship.TrainingType;
         ev.TrainingCode = apprenticeshipEvent.Apprenticeship.TrainingCode;
     }, GetLogMessage(apprenticeshipEvent)));
 }
Esempio n. 2
0
        public async Task PublishApprenticeshipCreated(IApprenticeshipEvent apprenticeshipEvent)
        {
            DateTime GetTransferApprovalOrAgreedOnDate()
            {
                if (apprenticeshipEvent.Commitment.TransferApprovalActionedOn.HasValue)
                {
                    return(apprenticeshipEvent.Commitment.TransferApprovalActionedOn.Value);
                }

                return(apprenticeshipEvent.Apprenticeship.AgreedOn.Value);
            }

            var logMessage = $"Publish {typeof(ApprenticeshipCreatedEvent).Name} message. {GetLogMessage(apprenticeshipEvent)}";

            try
            {
                DoPreChecks <ApprenticeshipCreatedEvent>(ApprenticePreChecks.HasStartAndEndDate, apprenticeshipEvent?.Apprenticeship);

                await _endpointInstance.Publish(new ApprenticeshipCreatedEvent
                {
                    ApprenticeshipId = apprenticeshipEvent.Apprenticeship.Id,
                    AgreedOn         = apprenticeshipEvent.Apprenticeship.AgreedOn.Value,
                    CreatedOn        = GetTransferApprovalOrAgreedOnDate(),
                    Uln        = apprenticeshipEvent.Apprenticeship.ULN,
                    ProviderId = apprenticeshipEvent.Apprenticeship.ProviderId,
                    AccountId  = apprenticeshipEvent.Apprenticeship.EmployerAccountId,
                    AccountLegalEntityPublicHashedId = apprenticeshipEvent.Apprenticeship.AccountLegalEntityPublicHashedId,
                    LegalEntityName  = apprenticeshipEvent.Commitment.LegalEntityName,
                    StartDate        = apprenticeshipEvent.Apprenticeship.StartDate.Value,
                    EndDate          = apprenticeshipEvent.Apprenticeship.EndDate.Value,
                    PriceEpisodes    = GetPriceEpisodes(apprenticeshipEvent.Apprenticeship),
                    TrainingType     = (CommitmentsV2.Types.ProgrammeType)apprenticeshipEvent.Apprenticeship.TrainingType,
                    TrainingCode     = apprenticeshipEvent.Apprenticeship.TrainingCode,
                    TransferSenderId = apprenticeshipEvent.Apprenticeship.TransferSenderId,
                    ApprenticeshipEmployerTypeOnApproval = apprenticeshipEvent.Commitment.ApprenticeshipEmployerTypeOnApproval
                });

                _logger.Info($"{logMessage} successful");
            }
            catch (Exception e)
            {
                _logger.Error(e, $"{logMessage} failed");
                throw;
            }
        }
Esempio n. 3
0
 private string GetLogMessage(IApprenticeshipEvent apprenticeshipEvent)
 {
     return
         ($"Provider:{apprenticeshipEvent.Commitment.ProviderId} Commitment:{apprenticeshipEvent.Commitment.Id} Apprenticeship:{apprenticeshipEvent.Apprenticeship.Id}");
 }