public override ValueInvestingCompanyDBModel WebClientAPICall(ValueInvestingCompanyDBModel company) { string Json = ""; WebClient client = new WebClient(); Json = client.DownloadString($"https://financialmodelingprep.com/api/v3/financials/cash-flow-statement/{ company.STOCK_TICKER}"); var OCJson = CashFlow_Top_Level.FromJson(Json); Console.WriteLine("Writting to Book Value DB"); foreach (var item in OCJson.Financials) { Dividends_DB_Model dividends = new Dividends_DB_Model { DATE = (item.Date), DIVIDENDS = (item.DividendPayments), STOCK_TICKER = company.STOCK_TICKER }; SQL.WriteDividendsData(dividends); } Random rnd = new Random(); company.DIVIDENDS = Convert.ToDouble(rnd.Next()); return(company); }
//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/financials/cash-flow-statement/{ company.STOCK_TICKER}"); //StockPriceModel Sp_json = JsonConvert.DeserializeObject<StockPriceModel>(Json); var OCJson = CashFlow_Top_Level.FromJson(Json); Console.WriteLine("Writting to Operating_Cash DB"); foreach (var item in OCJson.Financials) { Operating_Cash_DB_Model OperatingCash = new Operating_Cash_DB_Model { DATE = (item.Date), OPERATING_CASH_FLOW = (item.OperatingCashFlow), STOCK_TICKER = company.STOCK_TICKER }; SQL.WriteOperatingCashData(OperatingCash); } //Operating_Cash_DB_Model OperatingCash = new Operating_Cash_DB_Model { DATE = (OCJson.Symbol[0]), OPERATING_CASH_FLOW = OCJson. , STOCK_TICKER = company.STOCK_TICKER }; //SQL.WriteCurrentFinancialsData(StockPrice); Random rnd = new Random(); company.OPERATING_CASH = Convert.ToDouble(rnd.Next()); return(company); }