From ca49ba40658eb80fc6fcf605af53a26ecf74379e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 11 Jan 2023 14:15:18 +0100 Subject: [PATCH] Fix scrittura upsert device --- GPW.CORE.Data/Controllers/GPWController.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs index 602b032..db263b7 100644 --- a/GPW.CORE.Data/Controllers/GPWController.cs +++ b/GPW.CORE.Data/Controllers/GPWController.cs @@ -208,7 +208,7 @@ namespace GPW.CORE.Data.Controllers { try { - if (currItem.IdxRa == 0) + if (currItem.IdxDevice == 0) { localDbCtx.Entry(currItem).State = EntityState.Added; } @@ -225,12 +225,16 @@ namespace GPW.CORE.Data.Controllers oldRec.DataOraLastSeen = DateTime.Now; oldRec.Description = currItem.Description; oldRec.ScreenSize = currItem.ScreenSize; + localDbCtx + .DbSetAnagDevices + .Update(oldRec); } + // altrimenti aggiungo else { localDbCtx - .DbSetAnagDevices - .Add(currItem); + .DbSetAnagDevices + .Update(currItem); } } // ora salvo! @@ -239,7 +243,7 @@ namespace GPW.CORE.Data.Controllers } catch (Exception exc) { - Log.Error($"Errore in AnagDeviceInsert:{Environment.NewLine}{exc}"); + Log.Error($"Errore in AnagDeviceUpdate:{Environment.NewLine}{exc}"); } } return done;