PIMODGIR: CANCELLAZIONE PRIMA DI INSERIMENTO
This commit is contained in:
parent
531c0d7628
commit
f6642e7a27
@ -30,6 +30,20 @@ namespace ApiSoftway.Controllers
|
|||||||
//string usr = getClaimValueByToken(token, "codice");
|
//string usr = getClaimValueByToken(token, "codice");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//step 0: se esiste un record con quel seriale, prima cancello e poi inserisco di nuovo
|
||||||
|
_modgir = _modgiri_context.Mod;
|
||||||
|
List<Modgir> lst = _modgir.Where(t => t.Piserial.Equals(model.Piserial)).ToList();
|
||||||
|
foreach (Modgir item in lst)
|
||||||
|
{
|
||||||
|
using (var transaction = _modgiri_context.Database.BeginTransaction())
|
||||||
|
{
|
||||||
|
_modgiri_context.Entry(item).State = EntityState.Deleted;
|
||||||
|
await _modgiri_context.SaveChangesAsync();
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//step 1 : calcolo il nuovo seriale
|
//step 1 : calcolo il nuovo seriale
|
||||||
_modgir = _modgiri_context.Mod;
|
_modgir = _modgiri_context.Mod;
|
||||||
var ser = await _modgir.Take(1).OrderByDescending(t => t.Piprogre).ToListAsync();
|
var ser = await _modgir.Take(1).OrderByDescending(t => t.Piprogre).ToListAsync();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user