public async Task Handle(CreateIncentiveCommand command, CancellationToken cancellationToken = default) { var existing = await _apprenticeshipIncentiveDomainRepository.FindByApprenticeshipId(command.IncentiveApplicationApprenticeshipId); if (existing != null) { return; } var incentive = _apprenticeshipIncentiveFactory.CreateNew( Guid.NewGuid(), command.IncentiveApplicationApprenticeshipId, new Account(command.AccountId, command.AccountLegalEntityId), new Apprenticeship( command.ApprenticeshipId, command.FirstName, command.LastName, command.DateOfBirth, command.Uln, command.ApprenticeshipEmployerTypeOnApproval, command.CourseName ), command.PlannedStartDate, command.SubmittedDate, command.SubmittedByEmail); if (command.UKPRN.HasValue) { incentive.Apprenticeship.SetProvider(new Provider(command.UKPRN.Value)); } await _apprenticeshipIncentiveDomainRepository.Save(incentive); }
public async Task Handle(WithdrawCommand command, CancellationToken cancellationToken = default) { var incentive = await _domainRepository.FindByApprenticeshipId(command.IncentiveApplicationApprenticeshipId); if (incentive == null) { return; } await incentive.Withdraw(_collectionCalendarService); await _domainRepository.Save(incentive); }