Update x gestione metodi upsert

This commit is contained in:
2026-03-23 17:17:31 +01:00
parent 84144b4beb
commit 8c957edad8
31 changed files with 574 additions and 194 deletions
@@ -52,10 +52,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
dbCtx.DbSetJobTask.Remove(dbResult);
bool done = await dbCtx.SaveChangesAsync() > 0;
if (done)
tx.Commit();
return done;
}
catch
@@ -123,10 +123,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
dbCtx.Entry(currRec).State = EntityState.Modified;
bool done = await dbCtx.SaveChangesAsync() > 0;
if (done)
tx.Commit();
return done;
}
catch
@@ -163,7 +163,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
return false;
var otherRec = await dbCtx.DbSetJobTask
.FirstOrDefaultAsync(x => x.Index == newPos);
.FirstOrDefaultAsync(x => x.JobID == selRec.JobID && x.Index == newPos);
if (otherRec == null)
return false;
@@ -175,10 +175,10 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
dbCtx.Entry(currRec).State = EntityState.Modified;
bool done = await dbCtx.SaveChangesAsync() > 0;
if (done)
tx.Commit();
return done;
}
catch
@@ -191,7 +191,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Job
public async Task<bool> UpdateAsync(JobTaskModel entity)
{
await using var dbCtx = await CreateContextAsync();
var trackedEntity = dbCtx.DbSetJobTask.Local.FirstOrDefault(x => x.JobID == entity.JobID);
var trackedEntity = await dbCtx.DbSetJobTask.FirstOrDefaultAsync(x => x.JobID == entity.JobID);
if (trackedEntity != null)
{