Fix recupero ID x nuove door

This commit is contained in:
Samuele Locatelli
2023-03-30 12:49:54 +02:00
parent 961f4c2943
commit cb8e3a60bd
2 changed files with 11 additions and 9 deletions
@@ -403,8 +403,7 @@ namespace WebDoorCreator.Data.Controllers
/// <returns></returns>
public async Task<int> DoorInsert(DoorModel newRec)
{
int ordId = 0;
//List<ItemModel> dbResult = new List<ItemModel>();
int newId = 0;
using (WDCDataContext localDbCtx = new WDCDataContext(_configuration))
{
try
@@ -416,10 +415,11 @@ namespace WebDoorCreator.Data.Controllers
// procedo solo se non c'è già
if (currRec == null)
{
var newDbRec = localDbCtx
.DbSetDoor
.Add(newRec);
ordId= await localDbCtx.SaveChangesAsync();
var newDbRec = localDbCtx
.DbSetDoor
.Add(newRec);
await localDbCtx.SaveChangesAsync();
newId = newRec.DoorId;
}
}
catch (Exception exc)
@@ -427,7 +427,7 @@ namespace WebDoorCreator.Data.Controllers
Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}");
}
}
return ordId;
return newId;
}
/// <summary>