public static void SaveGasRecord(GasRecord record) { using (var ctx = new IotContext()) { ctx.GasRecords.Add(record); ctx.SaveChanges(); } }
public static void MarkException(AppException exception) { using (var db = new IotContext()) { db.AppExceptions.Remove(exception); db.SaveChanges(); } }
public static void SaveTemperatureRecord(TemperatureRecord record) { using (var ctx = new IotContext()) { ctx.TemperatureRecords.Add(record); ctx.SaveChanges(); } }
public static void Save(AppException exception) { using (var db = new IotContext()) { db.AppExceptions.Add(exception); db.SaveChanges(); } }
public static SystemIntegration SaveCultivations(SystemIntegration schedule) { if (schedule == null) { return(null); } DeviceService.InitData(); var tSchedule = schedule.CellCultivation; tSchedule.BatchNumber = CurrentContext.BatchNumber; tSchedule.CreatedAt = Common.Utility.Common.ToUnixTime(DateTime.Now); using (var db = new IotContext()) { db.CellCultivations.Add(tSchedule); db.SaveChanges(); } using (var db = new IotContext()) { schedule.Rocker.CultivationId = tSchedule.Id; db.Rockers.Add(schedule.Rocker); schedule.Gas.CultivationId = tSchedule.Id; db.Gases.Add(schedule.Gas); schedule.TemperatureGauge.DeviceId = tSchedule.Id; db.TemperatureGauges.Add(schedule.TemperatureGauge); var p = new List <Pump>() { schedule.PumpIn, schedule.PumpOut }; foreach (var each in p) { each.CultivationId = tSchedule.Id; db.Pumps.Add(each); } db.SaveChanges(); } return(schedule); }