public ActionResult Index() { LABU previousDayTimestampAlgoExampleLABU = dbcontext.LABU.OrderByDescending(t => t.timestamp).Take(1).FirstOrDefault(); string lastUpdatedAlgoExampleLABU = previousDayTimestampAlgoExampleLABU.timestamp; LABD previousDayTimestampAlgoExampleLABD = dbcontext.LABD.OrderByDescending(t => t.timestamp).Take(1).FirstOrDefault(); string lastUpdatedAlgoExampleLABD = previousDayTimestampAlgoExampleLABD.timestamp; JNUG previousDayTimestampAlgoExampleJNUG = dbcontext.JNUG.OrderByDescending(t => t.timestamp).Take(1).FirstOrDefault(); string lastUpdatedAlgoExampleJNUG = previousDayTimestampAlgoExampleJNUG.timestamp; ViewBag.AlgoExampleLABUClosePrice = previousDayTimestampAlgoExampleLABU.close.ToString(); ViewBag.AlgoExampleLABDClosePrice = previousDayTimestampAlgoExampleLABD.close.ToString(); ViewBag.AlgoExampleJNUGClosePrice = previousDayTimestampAlgoExampleJNUG.close.ToString(); ViewBag.lastUpdatedAlgoExampleLABU = lastUpdatedAlgoExampleLABU; ViewBag.lastUpdatedAlgoExampleLABD = lastUpdatedAlgoExampleLABD; ViewBag.lastUpdatedAlgoExampleJNUG = lastUpdatedAlgoExampleJNUG; string LABUTimeStamp = ""; using (var context = new AlpacaEntities()) { var HistoricalDBLABUTimeStamp = context.Database.SqlQuery <string>( "SELECT top 1 timestamp FROM [Historical_Data].[dbo].[LABU] order by ID desc").ToList(); LABUTimeStamp = HistoricalDBLABUTimeStamp[0]; } ViewBag.HistoricalDBLABUTimeStamp = LABUTimeStamp; string LABDTimeStamp = ""; using (var context = new AlpacaEntities()) { var HistoricalDBLABDTimeStamp = context.Database.SqlQuery <string>( "SELECT top 1 timestamp FROM [Historical_Data].[dbo].[LABD] order by ID desc").ToList(); LABDTimeStamp = HistoricalDBLABDTimeStamp[0]; } ViewBag.HistoricalDBLABDTimeStamp = LABDTimeStamp; string JNUGTimeStamp = ""; using (var context = new AlpacaEntities()) { var HistoricalDBJNUGTimeStamp = context.Database.SqlQuery <string>( "SELECT top 1 timestamp FROM [Historical_Data].[dbo].[JNUG] order by ID desc").ToList(); JNUGTimeStamp = HistoricalDBJNUGTimeStamp[0]; } ViewBag.HistoricalDBJNUGTimeStamp = JNUGTimeStamp; string AlgoExampleLABUUpdated = "false"; string AlgoExampleLABDUpdated = "false"; string AlgoExampleJNUGUpdated = "false"; string HistoricalDBLabuUpdated = "false"; string HistoricalDBLabdUpdated = "false"; string HistoricalDBJnugUpdated = "false"; string currentDate = DateTime.Now.ToString("yyyy-MM-dd"); string HistoricalDBlabuTimeStamp = LABUTimeStamp; string HistoricalDBLabdTimeStamp = LABDTimeStamp; string HistoricalDBJnugTimeStamp = JNUGTimeStamp; string AlgoExampleLABUTimeStamp = lastUpdatedAlgoExampleLABU; string AlgoExampleLABDTimeStamp = lastUpdatedAlgoExampleLABD; string AlgoExampleJNUGTimeStamp = lastUpdatedAlgoExampleJNUG; if (AlgoExampleLABUTimeStamp.Equals(currentDate + " 16:00:00")) { AlgoExampleLABUUpdated = "true"; } if (AlgoExampleLABDTimeStamp.Equals(currentDate + " 16:00:00")) { AlgoExampleLABDUpdated = "true"; } if (AlgoExampleJNUGTimeStamp.Equals(currentDate + " 16:00:00")) { AlgoExampleJNUGUpdated = "true"; } if (HistoricalDBlabuTimeStamp.Equals(currentDate + " 16:00:00")) { HistoricalDBLabuUpdated = "true"; } if (HistoricalDBLabdTimeStamp.Equals(currentDate + " 16:00:00")) { HistoricalDBLabdUpdated = "true"; } if (HistoricalDBJnugTimeStamp.Equals(currentDate + " 16:00:00")) { HistoricalDBJnugUpdated = "true"; } ViewBag.AlgoExampleLABUUpdated = AlgoExampleLABUUpdated; ViewBag.AlgoExampleLABDUpdated = AlgoExampleLABDUpdated; ViewBag.AlgoExampleJNUGUpdated = AlgoExampleJNUGUpdated; ViewBag.HistoricalDBLabuUpdated = HistoricalDBLabuUpdated; ViewBag.HistoricalDBLabdUpdated = HistoricalDBLabdUpdated; ViewBag.HistoricalDBJnugUpdated = HistoricalDBJnugUpdated; //List<Allocations> allocations = dbcontext.Allocations.ToList(); //ViewBag.Allocations = allocations; return(View()); }