@page "/" @rendermode InteractiveServer Home
@if (Session == null){

LOGIN

username
password
@loginError
}else{
UserName: @Session.UserName
}
@foreach (stockPredictionPair cur in predictions){

Symbol: @cur.Symbol


@if (cur.Movement == -1){

Sell

} else if (cur.Movement == 1){

Buy

} else{

Hold

}
}
@code { // User Stuff loginSession? Session = null; // Login Stuff string userName = ""; string passWord = ""; string loginError = ""; List predictions = new List(){ new stockPredictionPair(){ Symbol = "AAPL" }, new stockPredictionPair(){ Symbol = "AAPL" }, new stockPredictionPair(){ Symbol = "TTD" }, new stockPredictionPair(){ Symbol = "FUN" } }; async Task LoginSession(){ string dbPrefix = $"[{userName.ToLower()}]:"; // Set the DB prefix for the get and set string passwordhash = dbDriver.Get( dbPrefix + "password" ); // Pull the password hash if (BCrypt.Verify( passWord, passwordhash )){ // If the password is valid Session = new loginSession(){ UserName = userName.ToLower() }; }else{ loginError = "wrong password"; } } async Task registerSession(){ string dbPrefix = $"[{userName.ToLower()}]:"; string passwordhash = dbDriver.Get( dbPrefix + "password" ); if (string.IsNullOrEmpty(passwordhash)){ dbDriver.Set( dbPrefix + "password", BCrypt.HashPassword( passWord, BCrypt.GenerateSalt() ) ); Session = new loginSession(){ UserName = userName.ToLower() }; }else{ loginError = "account is taken"; } } // AI Stuff string button1Text = "Train AI"; string button2Text = "Predict AI"; async Task pullandtrain(){ button1Text = "Do not refresh the page. The data is refreshing."; await Task.Delay(1); aiModule.TrainAI(); button1Text = "Refresh Completed"; } async Task predict(){ button2Text = "Do not refresh the page. The data is refreshing."; await Task.Delay(1); List threadpool = new List(); foreach(stockPredictionPair cur in predictions){ Task thread = new Task(() => { cur.Movement = aiModule.PredictAI(cur.Symbol); Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement); }); thread.Start(); threadpool.Add(thread); } await Task.WhenAll(threadpool); button2Text = "Refresh Completed"; StateHasChanged(); await Task.Delay(1); } // Data Types class stockPredictionPair { public string Symbol { get; set; } = ""; public int Movement { get; set; } = 0; } class loginSession { public string UserName { get; set; } = ""; } }