forked from ddrilling/AsbCloudServer
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Services;
|
|
using AsbCloudDb.Model;
|
|
using AsbCloudInfrastructure.Services.Cache;
|
|
using Mapster;
|
|
|
|
namespace AsbCloudInfrastructure.Services
|
|
{
|
|
public class TelemetryDataSaubService: TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>
|
|
{
|
|
public TelemetryDataSaubService(
|
|
IAsbCloudDbContext db,
|
|
ITelemetryService telemetryService,
|
|
CacheDb cacheDb)
|
|
:base(db, telemetryService, cacheDb)
|
|
{}
|
|
|
|
public override TelemetryDataSaub Convert(TelemetryDataSaubDto src)
|
|
{
|
|
var entity = src.Adapt<TelemetryDataSaub>();
|
|
var telemetryUser = cacheTelemetryUsers?
|
|
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && (u.Name == src.User || u.Surname == src.User));
|
|
entity.IdUser = telemetryUser?.IdUser;
|
|
return entity;
|
|
}
|
|
|
|
public override TelemetryDataSaubDto Convert(TelemetryDataSaub src)
|
|
{
|
|
var dto = src.Adapt<TelemetryDataSaubDto>();
|
|
var telemetryUser = cacheTelemetryUsers?
|
|
.FirstOrDefault(u => u.IdTelemetry == src.IdTelemetry && u.IdUser == src.IdUser);
|
|
dto.User = telemetryUser?.MakeDisplayName();
|
|
return dto;
|
|
}
|
|
}
|
|
}
|