public List <Detail> GetAllMessageCatalogByIoTDeviceId(string deviceId) { DBHelper._IoTDeviceMessageCatalog dbhelp = new DBHelper._IoTDeviceMessageCatalog(); return(dbhelp.GetAllByIoTDeviceId(deviceId).Select(s => new Detail() { Id = s.Id, IoTHubDeviceId = s.IoTHubDeviceID, MessageCatalogId = s.MessageCatalogID, MessageCatalogName = (s.MessageCatalog == null) ? "" : s.MessageCatalog.Name }).ToList <Detail>()); }
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); }