Update add articoli (upsert)
This commit is contained in:
@@ -322,7 +322,7 @@ namespace MP.Data.Repository.Anag
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec)
|
||||
public async Task<bool> ArticoliUpsertAsync(AnagArticoliModel editRec)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var currRec = await dbCtx.DbSetArticoli.FirstOrDefaultAsync(x => x.CodArticolo == editRec.CodArticolo);
|
||||
@@ -333,9 +333,12 @@ namespace MP.Data.Repository.Anag
|
||||
currRec.Tipo = editRec.Tipo;
|
||||
currRec.Azienda = editRec.Azienda;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return false;
|
||||
else
|
||||
{
|
||||
dbCtx.DbSetArticoli.Add(editRec);
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user