2022-04-08 13:10:06 +05:00
|
|
|
|
using AsbCloudApp.Data.SAUB;
|
2021-09-17 16:24:01 +05:00
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using AsbCloudInfrastructure.Services.Cache;
|
|
|
|
|
using Mapster;
|
|
|
|
|
|
2022-04-11 18:00:34 +05:00
|
|
|
|
namespace AsbCloudInfrastructure.Services.SAUB
|
2021-09-17 16:24:01 +05:00
|
|
|
|
{
|
2022-04-11 18:00:34 +05:00
|
|
|
|
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>
|
2021-09-17 16:24:01 +05:00
|
|
|
|
{
|
|
|
|
|
public TelemetryDataSaubService(
|
|
|
|
|
IAsbCloudDbContext db,
|
|
|
|
|
ITelemetryService telemetryService,
|
|
|
|
|
CacheDb cacheDb)
|
2022-04-11 18:00:34 +05:00
|
|
|
|
: base(db, telemetryService, cacheDb)
|
|
|
|
|
{ }
|
2021-09-17 16:24:01 +05:00
|
|
|
|
|
2022-01-05 17:50:45 +05:00
|
|
|
|
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src, double timezoneOffset)
|
2021-09-17 16:24:01 +05:00
|
|
|
|
{
|
|
|
|
|
var entity = src.Adapt<TelemetryDataSaub>();
|
2021-09-23 10:53:48 +05:00
|
|
|
|
var telemetryUser = cacheTelemetryUsers?
|
2021-09-17 16:24:01 +05:00
|
|
|
|
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User));
|
2021-09-23 10:53:48 +05:00
|
|
|
|
entity.IdUser = telemetryUser?.IdUser;
|
2022-04-08 13:10:06 +05:00
|
|
|
|
entity.DateTime = src.DateTime.ToUtcDateTimeOffset(timezoneOffset);
|
2021-09-17 16:24:01 +05:00
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-05 17:50:45 +05:00
|
|
|
|
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset)
|
2021-09-17 16:24:01 +05:00
|
|
|
|
{
|
|
|
|
|
var dto = src.Adapt<TelemetryDataSaubDto>();
|
2021-09-23 10:53:48 +05:00
|
|
|
|
var telemetryUser = cacheTelemetryUsers?
|
2021-09-17 16:24:01 +05:00
|
|
|
|
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser);
|
2021-09-23 10:53:48 +05:00
|
|
|
|
dto.User = telemetryUser?.MakeDisplayName();
|
2022-04-08 13:10:06 +05:00
|
|
|
|
dto.DateTime = src.DateTime.ToRemoteDateTime(timezoneOffset);
|
2021-09-17 16:24:01 +05:00
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|