Skip to content

Commit

Permalink
fix #233 - Add builtin fields on device models and models commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Feb 13, 2022
1 parent 21187b1 commit 49628b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ public DeviceModelCommand GetDeviceModelCommand(TableEntity entity)
{
Name = entity.RowKey,
Frame = entity[nameof(DeviceModelCommand.Frame)].ToString(),
Port = int.Parse(entity[nameof(DeviceModelCommand.Port)].ToString())
Port = int.Parse(entity[nameof(DeviceModelCommand.Port)].ToString()),
IsBuiltin = bool.Parse(entity[nameof(DeviceModelCommand.IsBuiltin)].ToString()),
};
}

public void UpdateTableEntity(TableEntity commandEntity, DeviceModelCommand element)
{
commandEntity[nameof(DeviceModelCommand.Frame)] = element.Frame;
commandEntity[nameof(DeviceModelCommand.Port)] = element.Port;
commandEntity[nameof(DeviceModelCommand.IsBuiltin)] = element.IsBuiltin;
}
}
}
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Server/Mappers/DeviceModelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public DeviceModel CreateDeviceModel(TableEntity entity)
return new DeviceModel
{
ModelId = entity.RowKey,
IsBuiltin = bool.Parse(entity[nameof(DeviceModel.IsBuiltin)].ToString()),
ImageUrl = this.deviceModelImageManager.ComputeImageUri(entity.RowKey).ToString(),
Name = entity[nameof(DeviceModel.Name)]?.ToString(),
Description = entity[nameof(DeviceModel.Description)]?.ToString(),
Expand All @@ -38,6 +39,7 @@ public void UpdateTableEntity(TableEntity entity, DeviceModel model)
entity[nameof(DeviceModel.Description)] = model.Description;
entity[nameof(DeviceModel.AppEUI)] = model.AppEUI;
entity[nameof(DeviceModel.SensorDecoderURL)] = model.SensorDecoderURL;
entity[nameof(DeviceModel.IsBuiltin)] = model.IsBuiltin;
}
}
}
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal/Shared/Models/v1.0/DeviceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class DeviceModel

public string SensorDecoderURL { get; set; }

public bool IsBuiltin { get; set; }

[ValidateComplexType]
public List<DeviceModelCommand> Commands { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public class DeviceModelCommand
[Required(ErrorMessage = "The port number is required.")]
[Range(1, 223, ErrorMessage = "The port number should be between 1 and 223.")]
public int Port { get; set; } = 1;

public bool IsBuiltin { get; set; }
}
}

0 comments on commit 49628b8

Please sign in to comment.