private void AddDataVariable(TreatmentZone treatmentZone, NumericRepresentationValue value, string productId, IsoUnit unit) { if (value != null && value.Value != null) { var targetValue = value.Value.Value; // Convert input value to Iso unit var adaptUnit = unit.ToAdaptUnit(); UnitOfMeasure userUnit = null; if (adaptUnit != null && value.Value.UnitOfMeasure != null && adaptUnit.Dimension == value.Value.UnitOfMeasure.Dimension) { userUnit = value.Value.UnitOfMeasure; targetValue = _unitConverter.Convert(userUnit.ToInternalUom(), adaptUnit.ToInternalUom(), targetValue); } var dataVariable = new DataVariable { ProductId = productId, Value = targetValue, IsoUnit = unit, UserUnit = userUnit }; treatmentZone.Variables.Add(dataVariable); } }