public static void WriteCurrentStockPriceData(Current_StockPrice_DB_Model StockPrice) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("insert into Current_Stock_Price (ID, STOCK_PRICE, STOCK_TICKER) values (@ID, @STOCK_PRICE, @STOCK_TICKER)", StockPrice); } Console.WriteLine("Writting to Current_Stock_Price DB"); }
//making a webclient call syncly public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company) { string Json = ""; WebClient client = new WebClient(); Json = client.DownloadString($"https://financialmodelingprep.com/api/v3/stock/real-time-price/{ company.STOCK_TICKER}"); StockPriceModel Sp_json = JsonConvert.DeserializeObject <StockPriceModel>(Json); //writting to stock price db Current_StockPrice_DB_Model StockPrice = new Current_StockPrice_DB_Model { STOCK_PRICE = (Convert.ToDouble(Sp_json.Price)), STOCK_TICKER = company.STOCK_TICKER }; SQL.WriteCurrentStockPriceData(StockPrice); //assigning stock price to company object company.STOCK_PRICE = StockPrice.STOCK_PRICE; return(company); }