コード例 #1
0
        public async Task Then_data_is_fetched_from_database_for_an_account_with_a_single_legal_entity(string vrfCaseStatus)
        {
            // Arrange
            var        allAccounts = _fixture.CreateMany <Models.Account>(10).ToArray();
            const long accountId   = -1;

            allAccounts[0].Id            = accountId;
            allAccounts[0].VrfCaseStatus = vrfCaseStatus;

            _context.Accounts.AddRange(allAccounts);

            var allApplications = _fixture.CreateMany <Models.IncentiveApplication>(10).ToArray();

            for (var i = 0; i < 10; i++)
            {
                allApplications[i].AccountId            = allAccounts[i].Id;
                allApplications[i].AccountLegalEntityId = allAccounts[i].AccountLegalEntityId;
            }
            _context.Applications.AddRange(allApplications);

            _context.SaveChanges();

            // Act
            var actual = (await _sut.GetByVrfCaseStatus(vrfCaseStatus)).ToArray();

            //Assert
            actual.All(x => x.AccountId == accountId).Should().BeTrue();
            actual.Length.Should().Be(1);
            actual[0].LegalEntities.Count(x => x.AccountLegalEntityId == allAccounts[0].AccountLegalEntityId).Should().Be(1);
        }
コード例 #2
0
        public async Task Handle(AccountVrfCaseStatusRemindersCommand command, CancellationToken cancellationToken = default)
        {
            var accountsWithoutVrfStatus = await _accountDataRepository.GetByVrfCaseStatus(null);

            foreach (var account in accountsWithoutVrfStatus)
            {
                var applications = new List <ApprenticeApplicationDto>();

                foreach (var legalEntity in account.LegalEntities)
                {
                    var applicationsForLegalEntity = await _applicationDataRepository.GetList(account.AccountId, legalEntity.AccountLegalEntityId);

                    applications.AddRange(applicationsForLegalEntity);
                }

                var submittedApplications = applications.Where(x => x.ApplicationDate < command.ApplicationCutOffDate)
                                            .OrderBy(x => x.ApplicationDate);

                if (submittedApplications.Any())
                {
                    var application = submittedApplications.First();

                    var firstSubmittedApplicationId = await _applicationDataRepository.GetFirstSubmittedApplicationId(application.AccountLegalEntityId);

                    var sendRepeatReminderEmailCommand = new SendBankDetailsRepeatReminderEmailCommand(application.AccountId,
                                                                                                       application.AccountLegalEntityId,
                                                                                                       firstSubmittedApplicationId.Value,
                                                                                                       application.SubmittedByEmail);

                    await _commandDispatcher.Send(sendRepeatReminderEmailCommand);
                }
            }
        }
        public async Task <GetAccountsWithVrfCaseStatusResponse> Handle(GetAccountsWithVrfCaseStatusRequest query, CancellationToken cancellationToken = default)
        {
            var accounts = await _accountDataRepository.GetByVrfCaseStatus(query.VrfStatus);

            var response = new GetAccountsWithVrfCaseStatusResponse {
                Accounts = accounts
            };

            return(await Task.FromResult(response));
        }