public async Task<ActionResult> GetDeviceDetails(string deviceId) { IEnumerable<DevicePropertyValueModel> propModels; dynamic device = await _deviceLogic.GetDeviceAsync(deviceId); if (object.ReferenceEquals(device, null)) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } DeviceDetailModel deviceModel = new DeviceDetailModel() { DeviceID = deviceId, HubEnabledState = DeviceSchemaHelper.GetHubEnabledState(device), DevicePropertyValueModels = new List<DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); return PartialView("_DeviceDetails", deviceModel); }
public async Task<ActionResult> GetDeviceDetails(string deviceId) { IEnumerable<DevicePropertyValueModel> propModels; var device = await _deviceLogic.GetDeviceAsync(deviceId); if (device == null) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } if (device.DeviceProperties == null) { throw new DeviceRequiredPropertyNotFoundException("'DeviceProperties' property is missing"); } DeviceDetailModel deviceModel = new DeviceDetailModel { DeviceID = deviceId, HubEnabledState = device.DeviceProperties.GetHubEnabledState(), DevicePropertyValueModels = new List<DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); // check if value is cellular by checking iccid property deviceModel.IsCellular = device.SystemProperties.ICCID != null; deviceModel.Iccid = device.SystemProperties.ICCID; // todo: try get rid of null checks return PartialView("_DeviceDetails", deviceModel); }
public async Task<ActionResult> GetDeviceDetails(string deviceId) { IEnumerable<DevicePropertyValueModel> propModels; dynamic device = await _deviceLogic.GetDeviceAsync(deviceId); if (object.ReferenceEquals(device, null)) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } DeviceDetailModel deviceModel = new DeviceDetailModel { DeviceID = deviceId, HubEnabledState = DeviceSchemaHelper.GetHubEnabledState(device), DevicePropertyValueModels = new List<DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); // check if value is cellular by checking iccid property deviceModel.IsCellular = device.SystemProperties.ICCID != null; deviceModel.Iccid = device.SystemProperties.ICCID; // todo: try get rid of null checks return PartialView("_DeviceDetails", deviceModel); }