forked from ddrilling/AsbCloudServer
Fix TelemetryWirelineRunOut. AddOrUpdateAsync issue
This commit is contained in:
parent
f7654a95b6
commit
4dced662e1
@ -34,15 +34,11 @@ namespace AsbCloudInfrastructure.Repository
|
||||
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||
var timezoneOffset = telemetryService.GetTimezone(idTelemetry).Hours;
|
||||
var entity = Convert(idTelemetry, dto, timezoneOffset);
|
||||
|
||||
var updatingItem = context.TelemetryWirelineRunOut
|
||||
.Where(x => x.IdTelemetry == idTelemetry)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (updatingItem is null)
|
||||
context.TelemetryWirelineRunOut.Add(entity);
|
||||
else
|
||||
|
||||
if (await context.TelemetryWirelineRunOut.AnyAsync(w => w.IdTelemetry == idTelemetry, token))
|
||||
context.TelemetryWirelineRunOut.Update(entity);
|
||||
else
|
||||
context.TelemetryWirelineRunOut.Add(entity);
|
||||
|
||||
return await context.SaveChangesAsync(token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user