private async Task<decimal> TryUpdateDataChart(T_DataPoint point) { // Randomly choose whether to udpate this stock or not var rnd = new Random(); var pointValue = new T_DataValue(); pointValue.Value = rnd.Next(1, 100); pointValue.DateTime = DateTime.Now; pointValue.T_DataPoint = point.Id; db.T_DataValue.Add(pointValue); await db.SaveChangesAsync(); return pointValue.Value; }
private async void TryUpdateDataChart(List<T_DataPoint> _dataPoints) { var rnd = new Random(); var values = new ReturnChartData(); // Randomly choose whether to udpate this stock or not foreach ( var point in _dataPoints) { var pointValue = new T_DataValue(); pointValue.Value = rnd.Next(1, 100); pointValue.DateTime = DateTime.Now; pointValue.T_DataPoint = point.Id; db.T_DataValue.Add(pointValue); values.Values.Add(pointValue.Value); values.DateTime = pointValue.DateTime.ToString(); } Clients.Client(_clientId).updateChart(values); await db.SaveChangesAsync(); }