Update pagina composizione kit PODL
This commit is contained in:
@@ -2646,26 +2646,21 @@ namespace MP.Data.Controllers
|
||||
/// Elimina record
|
||||
/// </summary>
|
||||
/// <param name="rec2del"></param>
|
||||
public bool WipKitDelete(WipSetupKitModel rec2del)
|
||||
public async Task<bool> WipKitDeleteAsync(WipSetupKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
.FirstOrDefaultAsync();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == rec2del.KeyFilt && x.CodOrd == rec2del.CodOrd)
|
||||
.FirstOrDefault();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Remove(actRec);
|
||||
}
|
||||
return fatto;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2699,26 +2694,21 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="dateLimit"></param>
|
||||
/// <returns></returns>
|
||||
public bool WipKitDeleteOlder(DateTime dateLimit)
|
||||
public async Task<bool> WipKitDeleteOlderAsync(DateTime dateLimit)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.DataIns < dateLimit)
|
||||
.ToList();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.RemoveRange(actRec);
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
.ToListAsync();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.RemoveRange(actRec);
|
||||
}
|
||||
return fatto;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2746,35 +2736,30 @@ namespace MP.Data.Controllers
|
||||
/// Esegue upsert record
|
||||
/// </summary>
|
||||
/// <param name="editRec"></param>
|
||||
public bool WipKitUpsert(WipSetupKitModel editRec)
|
||||
public async Task<bool> WipKitUpsertAsync(WipSetupKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var actRec = await dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Add(editRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArt = editRec.CodArt;
|
||||
actRec.DescArt = editRec.DescArt;
|
||||
actRec.Qta = editRec.Qta;
|
||||
actRec.DataIns = editRec.DataIns;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.Add(editRec);
|
||||
}
|
||||
return fatto;
|
||||
else
|
||||
{
|
||||
actRec.CodArt = editRec.CodArt;
|
||||
actRec.DescArt = editRec.DescArt;
|
||||
actRec.Qta = editRec.Qta;
|
||||
actRec.DataIns = editRec.DataIns;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
Reference in New Issue
Block a user