public async Task Handle(RoundUpAdded notification, CancellationToken cancellationToken)
        {
            var savingsTransaction = _savingsService.CreateSavingsTransactionWhen(notification);
            await _savingsTransactionRepository.AddAsync(savingsTransaction);

            await _savingsTransactionRepository.SaveChangesAsync();
        }
示例#2
0
        public async Task Handle(SavingsAccountAdded notification, CancellationToken cancellationToken)
        {
            var savings = await _savingsService.CreateSavingsTransactionsWhen(notification);

            await Task.WhenAll(savings.Select(_savingsTransactionRepository.AddAsync));

            await _savingsTransactionRepository.SaveChangesAsync();

            var expenses = await _expenseRepository.FindByIban(notification.Iban);

            await Task.WhenAll(expenses.Select(x =>
            {
                x.Delete();
                return(_expenseRepository.UpdateAsync(x));
            }));

            await _expenseRepository.SaveChangesAsync();
        }
        public async Task Handle(BankTransferAdded notification, CancellationToken cancellationToken)
        {
            var savingsTransaction = await _savingsService.CreateSavingsTransactionWhen(notification);

            if (savingsTransaction != null)
            {
                await _savingsTransactionRepository.AddAsync(savingsTransaction);

                await _savingsTransactionRepository.SaveChangesAsync();
            }
            else
            {
                var expense = await _expenseService.CreateExpenseWhen(notification);

                if (expense != null)
                {
                    await _expenseRepository.AddAsync(expense);

                    await _expenseRepository.SaveChangesAsync();
                }
            }
        }
示例#4
0
        public async Task Handle(CollectionAdded notification, CancellationToken cancellationToken)
        {
            var savingsTransaction = await _savingsService.CreateSavingsTransactionWhen(notification);

            if (savingsTransaction != null)
            {
                await _savingsTransactionRepository.AddAsync(savingsTransaction);

                await _savingsTransactionRepository.SaveChangesAsync();
            }
            else
            {
                var income = await _incomeService.CreateIncomeWhen(notification);

                if (income != null)
                {
                    await _incomeRepository.AddAsync(income);

                    await _incomeRepository.SaveChangesAsync();
                }
            }
        }