public async Task <IEnumerable <IncentiveApplication> > FindByAccountLegalEntity(long accountLegalEntityId) { var applications = await _incentiveApplicationDataRepository.FindApplicationsByAccountLegalEntity(accountLegalEntityId); return(from app in applications select _incentiveApplicationFactory.GetExisting(app.Id, app)); }
public async Task Then_the_incentive_applications_for_the_account_legal_entity_are_returned() { // Arrange var apps = _fixture.CreateMany <Models.IncentiveApplication>(3).ToList(); apps[0].AccountLegalEntityId = 123; apps[1].AccountLegalEntityId = 456; apps[2].AccountLegalEntityId = 123; await _dbContext.AddRangeAsync(apps); await _dbContext.SaveChangesAsync(); // Act var result = await _sut.FindApplicationsByAccountLegalEntity(123); // Assert result.Should().NotBeNull(); result.Count().Should().Be(2); }
public async Task Handle(AccountLegalEntityRemoved @event, CancellationToken cancellationToken = default) { var applications = await _incentiveApplicationDataRepository.FindApplicationsByAccountLegalEntity(@event.AccountLegalEntityId); var withdrawTasks = new List <Task>(); foreach (var application in applications) { foreach (var apprenticeship in application.ApprenticeshipModels) { var withdrawCommand = new WithdrawCommand(application.AccountId, apprenticeship.Id); withdrawTasks.Add(_commandPublisher.Publish(withdrawCommand)); } } await Task.WhenAll(withdrawTasks); }