public async Task <ObjectResult> PostWallet([FromBody] Helpers.Transaction transaction) { //Get From balance var fromWallet = await _firebaseHelper.GetWalletAsync(transaction.From); //Check if transaction amount if (transaction.Amount > fromWallet.Balance) { return(BadRequest("The transaction amount is greater than the wallet balance.")); } //Save transaction if ok var result = await _firebaseHelper.AddTransactionAsync(transaction); //Deducte From wallet balance fromWallet.Balance = fromWallet.Balance - transaction.Amount; var updatedfromWallet = await _firebaseHelper.UpdateWalletAsync(transaction.From, fromWallet); return(Ok(result)); }