using AsbCloudApp.Data; using AsbCloudApp.Services; using AsbCloudDb.Model; using AsbCloudInfrastructure.Services.Cache; using Mapster; namespace AsbCloudInfrastructure.Services { public class TelemetryDataSaubService: TelemetryDataBaseService { public TelemetryDataSaubService( IAsbCloudDbContext db, ITelemetryService telemetryService, CacheDb cacheDb) :base(db, telemetryService, cacheDb) {} public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset) { var entity = src.Adapt(); var telemetryUser = cacheTelemetryUsers? .FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User)); entity.IdUser = telemetryUser?.IdUser; entity.Date = src.Date.ToUtcDateTimeOffset(timezoneOffset); return entity; } public override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset) { var dto = src.Adapt(); var telemetryUser = cacheTelemetryUsers? .FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser); dto.User = telemetryUser?.MakeDisplayName(); dto.Date = src.Date.ToRemoteDateTime(timezoneOffset); return dto; } } }