public bool WithdrawalExecuted(Withdraw withdraw) { // Set Withdraw status to confirm and update in database withdraw.StatusConfirmed(); _fundsPersistenceRepository.SaveOrUpdate(withdraw); Balance balance = _balanceRepository.GetBalanceByCurrencyAndAccountId(withdraw.Currency, withdraw.AccountId); if (balance != null) { bool addResponse = balance.ConfirmPendingTransaction(withdraw.WithdrawId, PendingTransactionType.Withdraw, -(withdraw.Amount + withdraw.Fee)); if (addResponse) { _fundsPersistenceRepository.SaveOrUpdate(balance); return(_transactionService.CreateWithdrawTransaction(withdraw, balance.CurrentBalance)); } } throw new InvalidOperationException("Balance not found for the given withdraw"); }