Refresh + fix gestione reparti-operatori
This commit is contained in:
@@ -270,38 +270,34 @@ namespace MP.Data.Controllers
|
||||
/// Elenco Gruppi tipo REPARTO (x associazione Macchine-Operatori) in formato DTO con conteggi del numero record trovati
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<RepartiDTO> AnagGruppiRepartoDTO()
|
||||
public async Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync()
|
||||
{
|
||||
List<RepartiDTO> dbResult = new List<RepartiDTO>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
// in primis recupero i reparti...
|
||||
var listReparti = AnagGruppiGetTipo("REPARTO");
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
// in primis recupero i reparti...
|
||||
var listReparti = AnagGruppiGetTipo("REPARTO");
|
||||
|
||||
// recupero TUTTE le macchine da DbSetGrp2Macc
|
||||
var listMacc = dbCtx
|
||||
// recupero TUTTE le macchine da DbSetGrp2Macc
|
||||
var listMacc = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
// recupero TUTTI gli operatori da DbSetGrp2Oper
|
||||
var listOpr = dbCtx
|
||||
.ToListAsync();
|
||||
// recupero TUTTI gli operatori da DbSetGrp2Oper
|
||||
var listOpr = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
.ToListAsync();
|
||||
|
||||
dbResult = listReparti
|
||||
.Select(x => new RepartiDTO()
|
||||
{
|
||||
CodGruppo = x.CodGruppo,
|
||||
TipoGruppo = x.TipoGruppo,
|
||||
DescrGruppo = x.DescrGruppo,
|
||||
SelEnabled = x.SelEnabled,
|
||||
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.IdxMacchina).Distinct().Count(),
|
||||
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.MatrOpr).Distinct().Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
return listReparti
|
||||
.Select(x => new RepartiDTO()
|
||||
{
|
||||
CodGruppo = x.CodGruppo,
|
||||
TipoGruppo = x.TipoGruppo,
|
||||
DescrGruppo = x.DescrGruppo,
|
||||
SelEnabled = x.SelEnabled,
|
||||
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.IdxMacchina).Distinct().Count(),
|
||||
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.MatrOpr).Distinct().Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1319,20 +1315,17 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="CodArtParent">Articolo KIT (fittizio)</param>
|
||||
/// <param name="KeyFilt">Chiave x filtro conf su tab WKS</param>
|
||||
public bool IstKitInsertByWKS(string CodArtParent, string KeyFilt)
|
||||
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
|
||||
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
|
||||
return dbResult > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user