Esempio n. 1
0
 public void InsertRegisterAtmosphere(AtmData atm)
 {
     try
     {
         using var context = new SmartCityZoneContext();
         context.Add(atm);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine("Problem connecting to DB when registering a AtmData");
         throw e;
     }
 }
        public void RegisterZoneAtm(ZoneAtmInfo zoneAtm)
        {
            var zoneAtmDataInfo = new AtmData
            {
                CO     = zoneAtm.Co,
                CO2    = zoneAtm.Co2,
                Date   = zoneAtm.date,
                HC     = zoneAtm.Hc,
                MP     = zoneAtm.MP,
                NOx    = zoneAtm.NOx,
                Rcho   = zoneAtm.Rcho,
                Sensor = _datagetter.QuerySensor(zoneAtm.Sensor),
                SOx    = zoneAtm.SOx
            };

            _zoneAtmReg.registerZoneAtm(zoneAtmDataInfo);
        }
Esempio n. 3
0
        public void registerZoneAtm(AtmData zoneAtmDataInfo)
        {
            try
            {
                using var context = new SmartCityZoneContext();

                zoneAtmDataInfo.Sensor = context.Sensors.ToList().Where(x => x.SensorId == zoneAtmDataInfo.Sensor.SensorId).First();

                context.Add(zoneAtmDataInfo);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine("Problem connecting to DB when registering a Atmosphere reading");
                throw e;
            }
        }