From b445a17280676ed42eebbecf25e73bd03e498c93 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 6 Feb 2024 17:10:13 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20modalit=C3=A0=20update/upsert...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MaterialsController.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/EgtBEAMWALL.DataLayer/Controllers/MaterialsController.cs b/EgtBEAMWALL.DataLayer/Controllers/MaterialsController.cs index 77c49095..89920a63 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/MaterialsController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/MaterialsController.cs @@ -289,8 +289,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers if (item2update != null) { - // update, vers 1... - localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem); + //// update, vers 1... + //localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem); + item2update.MatCloudId = updItem.MatCloudId; + item2update.MatDesc = updItem.MatDesc; + localDbCtx.Entry(item2update).State = System.Data.Entity.EntityState.Modified; // Commit changes localDbCtx.SaveChanges(); newIdx = item2update.MatId; @@ -325,8 +328,13 @@ namespace EgtBEAMWALL.DataLayer.Controllers if (item2update != null) { - // update, vers 1... - localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem); + //// update, vers 1... + //localDbCtx.Entry(item2update).CurrentValues.SetValues(updItem); + item2update.MatCloudId = updItem.MatCloudId; + item2update.MatDesc = updItem.MatDesc; + localDbCtx.Entry(item2update).State = System.Data.Entity.EntityState.Modified; + // Commit changes + localDbCtx.SaveChanges(); newIdx = item2update.MatId; } else