SPEC:
- continuo implementazione gestione KIT
This commit is contained in:
@@ -812,6 +812,87 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record
|
||||
/// </summary>
|
||||
/// <param name="rec2del"></param>
|
||||
public bool IstKitDelete(IstanzeKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = 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;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco istanze KIT da ricerca
|
||||
/// </summary>
|
||||
/// <param name="keyKit"></param>
|
||||
/// <param name="keyExtOrd"></param>
|
||||
/// <returns></returns>
|
||||
public List<IstanzeKitModel> IstKitFilt(string keyKit, string keyExtOrd)
|
||||
{
|
||||
List<IstanzeKitModel> dbResult = new List<IstanzeKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => (string.IsNullOrEmpty(keyKit) && string.IsNullOrEmpty(keyExtOrd)) || (x.KeyKit.Contains(keyKit) && !string.IsNullOrEmpty(keyKit)) || (x.KeyExtOrd.Contains(keyExtOrd) && !string.IsNullOrEmpty(keyExtOrd)))
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue upsert record
|
||||
/// </summary>
|
||||
/// <param name="editRec"></param>
|
||||
public bool IstKitUpsert(IstanzeKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInstKit
|
||||
.Where(x => x.KeyKit == editRec.KeyKit && x.KeyExtOrd == editRec.KeyExtOrd)
|
||||
.FirstOrDefault();
|
||||
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco giacenze
|
||||
/// </summary>
|
||||
@@ -1658,19 +1739,19 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco template da ricerca
|
||||
/// Elenco template KIT da ricerca
|
||||
/// </summary>
|
||||
/// <param name="codParent"></param>
|
||||
/// <param name="codCHild"></param>
|
||||
/// <param name="KitCode"></param>
|
||||
/// <param name="codChild"></param>
|
||||
/// <returns></returns>
|
||||
public List<TemplateKitModel> TemplateKitFilt(string codParent, string codChild)
|
||||
public List<TemplateKitModel> TemplateKitFilt(string KitCode, string codChild)
|
||||
{
|
||||
List<TemplateKitModel> dbResult = new List<TemplateKitModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetTempKit
|
||||
.Where(x => (string.IsNullOrEmpty(codParent) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(codParent) && !string.IsNullOrEmpty(codParent)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild)))
|
||||
.Where(x => (string.IsNullOrEmpty(KitCode) && string.IsNullOrEmpty(codChild)) || (x.CodArtParent.Contains(KitCode) && !string.IsNullOrEmpty(KitCode)) || (x.CodArtChild.Contains(codChild) && !string.IsNullOrEmpty(codChild)))
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
@@ -1700,8 +1781,6 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArtParent = editRec.CodArtParent;
|
||||
actRec.CodArtChild = editRec.CodArtChild;
|
||||
actRec.Qty = editRec.Qty;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
@@ -1729,6 +1808,143 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record
|
||||
/// </summary>
|
||||
/// <param name="rec2del"></param>
|
||||
public bool WipKitDelete(WipSetupKitModel rec2del)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
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;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina i record associati al KeyFilt indicato
|
||||
/// </summary>
|
||||
/// <param name="KeyFilt"></param>
|
||||
public bool WipKitDeleteGroup(string KeyFilt)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == KeyFilt)
|
||||
.ToList();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec != null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetWipKit
|
||||
.RemoveRange(actRec);
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina record + vecchi della data-ora indicata
|
||||
/// </summary>
|
||||
/// <param name="dateLimit"></param>
|
||||
/// <returns></returns>
|
||||
public bool WipKitDeleteOlder(DateTime dateLimit)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = 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;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco record WipSetupKit da KeyFilt
|
||||
/// </summary>
|
||||
/// <param name="KeyFilt"></param>
|
||||
/// <returns></returns>
|
||||
public List<WipSetupKitModel> WipKitFilt(string KeyFilt)
|
||||
{
|
||||
List<WipSetupKitModel> dbResult = new List<WipSetupKitModel>();
|
||||
// solo se filtro valido...
|
||||
if (!string.IsNullOrEmpty(KeyFilt))
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt.Contains(KeyFilt))
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue upsert record
|
||||
/// </summary>
|
||||
/// <param name="editRec"></param>
|
||||
public bool WipKitUpsert(WipSetupKitModel editRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetWipKit
|
||||
.Where(x => x.KeyFilt == editRec.KeyFilt && x.CodOrd == editRec.CodOrd)
|
||||
.FirstOrDefault();
|
||||
|
||||
// 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;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
Reference in New Issue
Block a user