public Alarm getAlarmById(int id) { var alarm = new Alarm(); using (var db = new HealthModelsDataContext()) { var query = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.id == id); alarm = query; } return alarm; }
//get Alarm public Alarm getAlarm(string name) { var alarm = new Alarm(); using (var db = new HealthModelsDataContext()) { var query = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.name.Equals(name)); alarm = query; } return alarm; }
//create Alarm public void createAlarm(string name, string type, string location, string status) { using (var db = new HealthModelsDataContext()) { var alarm = new Alarm(); alarm.name = name; alarm.type = type; alarm.time = DateTime.Now; alarm.location = location; alarm.status = status; db.Alarms.InsertOnSubmit(alarm); db.SubmitChanges(); } }
//update Alarm public void updateAlarm(string name, string type, string location, string status) { var alarm = new Alarm(); using (var db = new HealthModelsDataContext()) { alarm = db.Alarms.SingleOrDefault(targetAlarm => targetAlarm.name.Equals(name)); if (alarm!=null) { alarm.name = name; alarm.type = type; alarm.time = DateTime.Now; alarm.location = location; alarm.status = status; db.SubmitChanges(); } } }
partial void DeleteAlarm(Alarm instance);
partial void UpdateAlarm(Alarm instance);
partial void InsertAlarm(Alarm instance);