public void UpdateAllAlarmRules(int alarmRuleCatalogId, Edit input) { DBHelper._AlarmRuleItem dbhelp = new DBHelper._AlarmRuleItem(); List <AlarmRuleItem> existAlarmRuleItemList = dbhelp.GetAllByAlarmRuleCatalogId(alarmRuleCatalogId); List <AlarmRuleItem> addList = new List <AlarmRuleItem>(); dbhelp.Delete(existAlarmRuleItemList); foreach (var tmp in input.AlarmRules) { AlarmRuleItem alarmRuleItem = new AlarmRuleItem(); alarmRuleItem.AlarmRuleCatalogId = alarmRuleCatalogId; alarmRuleItem.Ordering = tmp.Ordering; alarmRuleItem.MessageElementId = tmp.MessageElementId; alarmRuleItem.EqualOperation = tmp.EqualOperation; alarmRuleItem.Value = tmp.Value; alarmRuleItem.BitWiseOperation = tmp.BitWiseOperation; if (tmp.MessageElementParentId != null) { alarmRuleItem.MessageElementParentId = tmp.MessageElementParentId; } addList.Add(alarmRuleItem); } dbhelp.Add(addList); }
public Detail getAlarmRuleItemById(int id) { DBHelper._AlarmRuleItem dbhelp = new DBHelper._AlarmRuleItem(); AlarmRuleItem alarmRuleItem = dbhelp.GetByid(id); return(new Detail() { Id = alarmRuleItem.Id, AlarmRuleCatalogId = alarmRuleItem.AlarmRuleCatalogId, Ordering = alarmRuleItem.Ordering, MessageElementParentId = alarmRuleItem.MessageElementParentId, MessageElementId = alarmRuleItem.MessageElementId, MessageElementName = alarmRuleItem.MessageElement1.ElementName, EqualOperation = alarmRuleItem.EqualOperation, Value = alarmRuleItem.Value, BitWiseOperation = alarmRuleItem.BitWiseOperation }); }