private async Task <bool> DestinationAccountNotReachItsLimit(TransferFundCommand request) { var account = _unitOfWork.Account.GetFirstOrDefault(a => a.AccountNumber == request.DestinationAccount); var inquireBalanceEvent = new InquireBalance { AccountId = account.AccountId, Balance = account.Balance, TransactionAmount = request.Amount, Status = (MAXIMUM_ALLOWABLE_AMOUNT_ON_ACCOUNT >= (account.Balance + request.Amount) ? TransactionStatus.SUCCESS : TransactionStatus.REACH_MAXIMUM_ALLOWABLE_AMOUNT) }; await _messagePublisher.PublishMessageAsync(inquireBalanceEvent.MessageType, inquireBalanceEvent, ""); return(MAXIMUM_ALLOWABLE_AMOUNT_ON_ACCOUNT >= (account.Balance + request.Amount)); }
private async Task <bool> HasValidTransactionAmount(WithdrawCommand request) { var account = _unitOfWork.Account.GetFirstOrDefault(a => a.AccountNumber == request.AccountNumber); var inquireBalanceEvent = new InquireBalance { AccountId = account.AccountId, Balance = account.Balance, TransactionAmount = request.Amount, Status = (request.Amount <= account.Balance ? TransactionStatus.SUCCESS : TransactionStatus.INSUFFICIENT_FUNDS) }; await _messagePublisher.PublishMessageAsync(inquireBalanceEvent.MessageType, inquireBalanceEvent, ""); return(request.Amount <= account.Balance); }
private async Task <bool> SourceHasSufficientAmount(TransferFundCommand request) { var account = _unitOfWork.Account.GetFirstOrDefault(a => a.AccountNumber == request.SourceAccount); var inquireBalanceEvent = new InquireBalance { AccountId = account.AccountId, Balance = account.Balance, TransactionAmount = request.Amount, Status = (account.Balance >= request.Amount ? TransactionStatus.SUCCESS : TransactionStatus.INSUFFICIENT_FUNDS) }; await _messagePublisher.PublishMessageAsync(inquireBalanceEvent.MessageType, inquireBalanceEvent, ""); return(account.Balance >= request.Amount); }