public async Task <DepositPaymentTransactionDTO> MakeDepositPaymentTransaction(string uniqueMasterCitizenNumber, string password, decimal amount) { Wallet wallet = await CheckForWallet(uniqueMasterCitizenNumber, password); IBankAPI bankAPI = _bankAPIDeterminator.DeterminateBankAPI(wallet.SupportedBank); DepositPaymentTransaction depositPaymentTransaction = wallet.MakeDepositTransaction(amount); bool successWithdrawal = await bankAPI.Withdraw(uniqueMasterCitizenNumber, wallet.PostalIndexNumber, amount); if (!successWithdrawal) { wallet.DeletePaymentTransaction(depositPaymentTransaction); throw new BankAPIException("Bank api - failed to withdrawal"); } await _unitOfWork.PaymentTransactionRepository.Insert(depositPaymentTransaction); await _unitOfWork.SaveChangesAsync(); return(new DepositPaymentTransactionDTO(depositPaymentTransaction)); }
public DepositPaymentTransactionDTO(DepositPaymentTransaction paymentTransaction) : base(paymentTransaction) { }