diff --git a/WebServer/Components/Pages/Home.razor b/WebServer/Components/Pages/Home.razor
index cc669aee..940bde83 100644
--- a/WebServer/Components/Pages/Home.razor
+++ b/WebServer/Components/Pages/Home.razor
@@ -49,9 +49,15 @@
}
-
-
-
+ @if (Debounce){
+
+
+
+ } else {
+
+
+
+ }
@resultError
@@ -71,7 +77,11 @@
Purchased Price: @cur.PurchasePrice
Purchased Quantity: @cur.Quantity
Purchased Date: @cur.PurchaseDate.ToString("M-dd-yyyy")
-
+ @if (Debounce){
+
+ }else{
+
+ }
->
@@ -218,6 +228,7 @@
await Task.Delay(2000);
predictButtonText = "Predict AI";
Debounce = true;
+ await Task.Delay(1);
}
}
@@ -231,13 +242,18 @@
string buyStockSymbol = "";
string buyStockQuantity = "";
- void buyStock(){
- if (Session != null){
+ async Task buyStock(){
+ if (Debounce && Session != null){
+ Debounce = false;
+ await Task.Delay(1);
+
string dbPrefix = $"[{userName.ToLower()}]:";
// Try Parse the quantitiy input
bool success = float.TryParse(buyStockQuantity, out float QuantityResult);
if (!success){
resultError = "Quantity field is not a number";
+ Debounce = true;
+ await Task.Delay(1);
return;
}
@@ -248,6 +264,8 @@
(bool, string) result = PaymentProcessor.TryPayment(PaymentKey, QuantityResult * stockPrice);
if (!result.Item1){
resultError = result.Item2;
+ Debounce = true;
+ await Task.Delay(1);
return;
}
@@ -268,15 +286,21 @@
result = PaymentProcessor.CreatePayment(Session.UserName);
if (!result.Item1){
resultError = "[New payment session failed] : " + result.Item2;
+ Debounce = true;
+ await Task.Delay(1);
return;
}
PaymentKey = result.Item2;
+ Debounce = true;
+ await Task.Delay(1);
}
}
- void sellStock(PurchasedStock stock){
+ async Task sellStock(PurchasedStock stock){
string dbPrefix = $"[{userName.ToLower()}]:";
- if (Session != null){
+ if (Debounce && Session != null){
+ Debounce = false;
+ await Task.Delay(1);
// Get sell price
float sellPrice = stock.Quantity * aiModule.GetCurrentPrice( stock.Symbol );
@@ -285,6 +309,8 @@
(bool, string) result = PaymentProcessor.TrySell(PaymentKey, sellPrice);
if (!result.Item1){
resultError = result.Item2;
+ Debounce = true;
+ await Task.Delay(1);
return;
}
@@ -300,9 +326,14 @@
result = PaymentProcessor.CreatePayment(Session.UserName);
if (!result.Item1){
resultError = "[New payment session failed] : " + result.Item2;
+ Debounce = true;
+ await Task.Delay(1);
return;
}
PaymentKey = result.Item2;
+
+ Debounce = true;
+ await Task.Delay(1);
}
}
}
\ No newline at end of file