Ok gestione eliminazione KIT
This commit is contained in:
@@ -1264,26 +1264,21 @@ namespace MP.Data.Controllers
|
||||
/// Elimina record
|
||||
/// </summary>
|
||||
/// <param name="rec2del"></param>
|
||||
public bool IstKitDelete(IstanzeKitModel rec2del)
|
||||
public async Task<bool> IstKitDeleteAsync(IstanzeKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == rec2del.KeyKit && x.KeyExtOrd == rec2del.KeyExtOrd)
|
||||
.FirstOrDefault();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetInstKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
.FirstOrDefaultAsync();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetInstKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return fatto;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1324,35 +1319,30 @@ namespace MP.Data.Controllers
|
||||
/// Esegue upsert record
|
||||
/// </summary>
|
||||
/// <param name="editRec"></param>
|
||||
public bool IstKitUpsert(IstanzeKitModel editRec)
|
||||
public async Task<bool> IstKitUpsertAsync(IstanzeKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
await dbCtx
|
||||
.DbSetInstKit
|
||||
.Add(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArtParent = editRec.CodArtParent;
|
||||
actRec.CodArtChild = editRec.CodArtChild;
|
||||
actRec.QtyART = editRec.QtyART;
|
||||
actRec.QtyKIT = editRec.QtyKIT;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
.AddAsync(editRec);
|
||||
}
|
||||
return fatto;
|
||||
else
|
||||
{
|
||||
actRec.CodArtParent = editRec.CodArtParent;
|
||||
actRec.CodArtChild = editRec.CodArtChild;
|
||||
actRec.QtyART = editRec.QtyART;
|
||||
actRec.QtyKIT = editRec.QtyKIT;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1468,22 +1458,17 @@ namespace MP.Data.Controllers
|
||||
/// <param name="CodArticolo"></param>
|
||||
/// <param name="OnlyAvail">True = aperti (=senza ODL)</param>
|
||||
/// <returns></returns>
|
||||
public List<PODLExpModel> ListPODL_ByCodArt(string CodArticolo, bool OnlyAvail)
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByCodArtAsync(string CodArticolo, bool OnlyAvail)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var pCodArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
var pOnlyAvail = new SqlParameter("@onlyAvail", OnlyAvail);
|
||||
|
||||
dbResult = dbCtx
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByCodArt @CodArticolo, @onlyAvail", pCodArticolo, pOnlyAvail)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return dbResult;
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1491,20 +1476,16 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="IdxPodlParent">IDX PODL parent</param>
|
||||
/// <returns></returns>
|
||||
public List<PODLExpModel> ListPODL_ByKitParent(int IdxPodlParent)
|
||||
public async Task<List<PODLExpModel>> ListPODL_ByKitParentAsync(int IdxPodlParent)
|
||||
{
|
||||
List<PODLExpModel> dbResult = new List<PODLExpModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var pIdxPodlParent = new SqlParameter("@IdxPodlParent", IdxPodlParent);
|
||||
|
||||
dbResult = dbCtx
|
||||
return await dbCtx
|
||||
.DbSetPODLExp
|
||||
.FromSqlRaw("EXEC stp_PODL_getByParentKitIdx @IdxPodlParent", pIdxPodlParent)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2369,19 +2350,15 @@ namespace MP.Data.Controllers
|
||||
/// Effettua il task di eliminazione PODL KIT + istanze + riattivazione PODL originali disattivate tramite stored
|
||||
/// </summary>
|
||||
/// <param name="IdxPODL">IdxPODL parent</param>
|
||||
public bool PodlIstKitDelete(int IdxPODL)
|
||||
public async Task<bool> PodlIstKitDeleteAsync(int IdxPODL)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var pIdxPODL = new SqlParameter("@IdxPODL", IdxPODL);
|
||||
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC dbo.stp_PodlIstKit_delete @IdxPODL", pIdxPODL);
|
||||
answ = dbResult != 0;
|
||||
}
|
||||
return answ;
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_PodlIstKit_delete @IdxPODL", pIdxPODL);
|
||||
return dbResult != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user