public void addIoTDeviceMessageCatalog(string deviceId, Edit IoTDMC) { DBHelper._IoTDeviceMessageCatalog dbhelp = new DBHelper._IoTDeviceMessageCatalog(); List <IoTDeviceMessageCatalog> newIoTDMCList = new List <IoTDeviceMessageCatalog>(); foreach (int messageCatalogId in IoTDMC.MessageCatalogIdList) { newIoTDMCList.Add(new IoTDeviceMessageCatalog() { IoTHubDeviceID = deviceId, MessageCatalogID = messageCatalogId }); } dbhelp.Add(newIoTDMCList); }
public void AttachMessage(string deviceId, Edit iotDMC) { DBHelper._IoTDeviceMessageCatalog dbhelp = new DBHelper._IoTDeviceMessageCatalog(); List <IoTDeviceMessageCatalog> newIoTDMCList = new List <IoTDeviceMessageCatalog>(); List <IoTDeviceMessageCatalog> existIoTDMCList = dbhelp.GetAllByIoTDeviceId(deviceId); dbhelp.Delete(existIoTDMCList); if (iotDMC != null) { foreach (int messageCatalogId in iotDMC.MessageCatalogIdList) { newIoTDMCList.Add(new IoTDeviceMessageCatalog() { IoTHubDeviceID = deviceId, MessageCatalogID = messageCatalogId }); } } dbhelp.Add(newIoTDMCList); }