Beispiel #1
0
        public async Task <Unit> Handle(
            CreateApprenticeshipCommand command,
            CancellationToken cancellationToken)
        {
            var(trainingProvider, apprentice, course) = await GetExternalData(command);

            var id = Guid.NewGuid();

            await _apprenticeCommitmentsService.CreateApprenticeship(new CreateApprenticeshipRequestData
            {
                ApprenticeId                 = id,
                ApprenticeshipId             = command.ApprenticeshipId,
                Email                        = command.Email,
                EmployerName                 = command.EmployerName,
                EmployerAccountLegalEntityId = command.EmployerAccountLegalEntityId,
                TrainingProviderId           = command.TrainingProviderId,
                TrainingProviderName         = string.IsNullOrWhiteSpace(trainingProvider.TradingName) ? trainingProvider.LegalName : trainingProvider.TradingName,
                CourseName                   = course.Title,
                CourseLevel                  = course.Level,
                PlannedStartDate             = apprentice.StartDate,
                PlannedEndDate               = apprentice.EndDate,
            });

            await _apprenticeLoginService.SendInvitation(new SendInvitationModel
            {
                SourceId           = id,
                Email              = command.Email,
                GivenName          = apprentice.FirstName,
                FamilyName         = apprentice.LastName,
                OrganisationName   = command.EmployerName,
                ApprenticeshipName = apprentice.CourseName,
            });

            return(Unit.Value);
        }