Пример #1
0
        public void Post(Measurement measurement)
        {
            if (measurement == null)
            {
                measurement = new Measurement { SensorId = 1, LastUpdated = DateTime.Now, Temp = 10 };
            }

            MeasurementBC.AddMeasurement(measurement);
        }
Пример #2
0
        public void AddMeasurement(Measurement measurement)
        {
            var modyfied = false;
            var sensor = SensorBC.GetSensor(measurement.SensorId);

            if (sensor == null)
            {
                sensor = new Sensor { TdSensorId = measurement.SensorId, Measurements = new List<Measurement>() };
                DbContext.Sensors.Add(sensor);
                modyfied = true;
            }

            var timeDiff = GetTimeDiffOfNearestMeasurement(sensor.Measurements, measurement.LastUpdated);

            if (timeDiff.TotalHours > 1) // TODO: get from application settings
            {
                sensor.Measurements.Add(measurement);
                modyfied = true;
            }

            if (modyfied)
                DbContext.SaveChanges();
        }
 public void Post(Measurement measurement)
 {
     throw new NotImplementedException();
 }