/// <summary> /// Retrieve bank account for the specified id /// </summary> /// <param name="accountId"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <ApiResponse <BankAccountResponse> > GetBankAccountByIdAsync(int accountId, CancellationToken cancellationToken = default) { var responseModel = new ApiResponse <BankAccountResponse>(); var bankAccount = await _bankAccountRepo.FindByIdAsync(accountId); if (bankAccount == null) { responseModel.AddError(ExceptionCreator.CreateNotFoundError(nameof(bankAccount), $"bank account Id: {accountId} Not found")); return(responseModel); } var accountOwner = CreateBankAccountOwner(bankAccount); var lastTransaction = await _cashTransactionsRepo.GetLastAsync(bankAccount.IBAN); responseModel.Data = CreateBankAccountResponse(bankAccount, accountOwner, lastTransaction.CreatedAt); return(responseModel); }
private async Task <FastTransactionResponse> CreateFastTransactionResponse(FastTransaction transaction) { if (transaction != null) { var branch = await _branchRepo.FindByIdAsync(transaction.BranchId); if (branch == null) { return(null); } var bankAccount = await _bankAccountRepo.FindByIdAsync(transaction.AccountId); if (bankAccount == null) { return(null); } return(new FastTransactionResponse(transaction.Id, bankAccount.IBAN, branch.Name, transaction.RecipientName, transaction.RecipientIBAN)); } return(null); }