Пример #1
0
        public async Task ScrapeBankDataAsync(IBankConnectionData connectionData)
        {
            var bankData = await GetBankDataAsync(connectionData);

            if (bankData == null)
            {
                return;
            }

            var account = _mapper.Map <Account>(bankData.Account);

            account.Bank = bankData.Bank;

            if (bankData.Customer != null)
            {
                var customer = _mapper.Map <Customer>(bankData.Customer);
                await _customersService.AddAsync(customer);

                account.Customer   = customer;
                account.CustomerId = customer.Id;
            }

            await _accountsService.AddAsync(account);

            await SaveBillsAsync(bankData.Bills, account);
            await SaveCardsAsync(bankData.Cards, account);
            await SaveTransactionsAsync(bankData.Transactions, account);
        }