From 16bd6749fdd5abba88662acdde3bc33920f08b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Fri, 3 Sep 2021 11:35:49 +0500 Subject: [PATCH] fix telemetry user id mapping --- AsbCloudInfrastructure/Services/DataService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index 0e5fd2f9..277f0a1d 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -18,6 +18,7 @@ namespace AsbCloudInfrastructure.Services private readonly ITelemetryService telemetryService; private readonly ITelemetryAnalyticsService analyticsService; private readonly CacheTable cacheTelemetry; + private readonly CacheTable cacheTelemetryUsers; private readonly CacheTable cacheWells; public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService, @@ -27,6 +28,7 @@ namespace AsbCloudInfrastructure.Services this.telemetryService = telemetryService; this.analyticsService = analyticsService; cacheTelemetry = cacheDb.GetCachedTable((AsbCloudDbContext)db); + cacheTelemetryUsers = cacheDb.GetCachedTable((AsbCloudDbContext)db); cacheWells = cacheDb.GetCachedTable((AsbCloudDbContext)db); } @@ -94,10 +96,13 @@ namespace AsbCloudInfrastructure.Services if (oldDataSaubBase.Any()) db.DataSaubBases.RemoveRange(oldDataSaubBase); - foreach (var dto in dtos) { var dataSaub = dto.Adapt(); + var telemetryUser = await cacheTelemetryUsers + .FirstOrDefaultAsync(u => u.IdTelemetry == telemetryId && (u.Name == dto.User || u.Surname == dto.User), token) + .ConfigureAwait(false); + dataSaub.IdUser = telemetryUser?.IdUser; dataSaub.IdTelemetry = telemetryId; db.DataSaubBases.Add(dataSaub);