diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs index a13bbac0..2bd79b87 100644 --- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs +++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs @@ -96,17 +96,17 @@ namespace AsbCloudInfrastructure.Repository var jsonValue = item.Value; if(jsonValue.value is string valueString) { - var entity = ConvertToEntity(dto, valueString, item.Key, timezoneHours); + var entity = ConvertToEntity(dto, valueString, timezoneHours); db.WitsItemString.Add(entity.Adapt()); } if (jsonValue.value is float valueFloat) { - var entity = ConvertToEntity(dto, valueFloat, item.Key, timezoneHours); + var entity = ConvertToEntity(dto, valueFloat, timezoneHours); db.WitsItemFloat.Add(entity.Adapt()); } if (jsonValue.value is int valueInt) { - var entity = ConvertToEntity(dto, valueInt, item.Key, timezoneHours); + var entity = ConvertToEntity(dto, valueInt, timezoneHours); db.WitsItemInt.Add(entity.Adapt()); } } @@ -150,17 +150,12 @@ namespace AsbCloudInfrastructure.Repository }); return items; } - private static WitsItemBase ConvertToEntity(WitsRecordDto record, Tvalue value, int idItems, double timezoneHours) + private static WitsItemBase ConvertToEntity(WitsRecordDto record, Tvalue value, double timezoneHours) where Tvalue: notnull { - var entity = new WitsItemBase - { - IdTelemetry = record.IdTelemetry, - DateTime = record.Date.ToUtcDateTimeOffset(timezoneHours), - IdRecord = record.Id, - IdItem = idItems, - Value = value, - }; + var entity = record.Adapt>(); + entity.DateTime = record.Date.ToUtcDateTimeOffset(timezoneHours); + entity.Value = value; return entity; }