Inizio setup repository
This commit is contained in:
@@ -0,0 +1,417 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Anag
|
||||
{
|
||||
public class AnagRepository : BaseRepository, IAnagRepository
|
||||
{
|
||||
public AnagRepository(IDbContextFactory<MoonProContext> ctxFactory) : base(ctxFactory)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<AnagCountersModel> AnagCountersGetNextAsync(string cntType)
|
||||
{
|
||||
AnagCountersModel answ = new AnagCountersModel();
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
bool outTable = true;
|
||||
if (outTable)
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
|
||||
var dbResult = await dbCtx
|
||||
.DbSetAnagCount
|
||||
.FromSqlRaw("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT", pCntType, pLastNum)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
answ = dbResult;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var pCntType = new SqlParameter("@CntType", cntType);
|
||||
var pLastNum = new SqlParameter
|
||||
{
|
||||
ParameterName = "@LastNum",
|
||||
SqlDbType = SqlDbType.Int,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var pCntCode = new SqlParameter
|
||||
{
|
||||
ParameterName = "@CntCode",
|
||||
SqlDbType = SqlDbType.NVarChar,
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
var dbResult = await dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRawAsync("EXEC dbo.stp_getNextNumb @CntType, @LastNum OUTPUT, @CntCode OUTPUT", pCntType, pLastNum, pCntCode);
|
||||
if (dbResult != 0)
|
||||
{
|
||||
answ.CntType = cntType;
|
||||
answ.CntCode = $"{pCntCode.Value}";
|
||||
int lNum = 0;
|
||||
int.TryParse($"{pLastNum.Value}", out lNum);
|
||||
answ.LastNum = lNum;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync(string TableName = "EvList", string FieldName = "Common")
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var pTableName = new SqlParameter("@TableName", TableName);
|
||||
var pFieldName = new SqlParameter("@FieldName", FieldName);
|
||||
var dbResult = await dbCtx
|
||||
.DbSetVSEB
|
||||
.FromSqlRaw("exec dbo.stp_vseb_getGenerallyAvailable @TableName, @FieldName", pTableName, pFieldName)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult ?? new();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagGruppiModel>> AnagGruppiAziendeAsync()
|
||||
{
|
||||
return await AnagGruppiGetTipoAsync("AZIENDA");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AnagGruppiDeleteAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
.Where(x => x.CodGruppo == updRec.CodGruppo)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbCtx.DbSetAnagGruppi.Remove(dbRec);
|
||||
}
|
||||
var numRes = await dbCtx.SaveChangesAsync();
|
||||
return numRes != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagGruppiModel>> AnagGruppiFaseAsync()
|
||||
{
|
||||
return await AnagGruppiGetTipoAsync("FASE");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagGruppiModel>> AnagGruppiGetTipoAsync(string tipoGruppo)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.Where(x => x.TipoGruppo == tipoGruppo)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.CodGruppo)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var listReparti = await AnagGruppiGetTipoAsync("REPARTO");
|
||||
|
||||
var listMacc = await dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
var listOpr = await dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
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(y => y.IdxMacchina).Distinct().Count(),
|
||||
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(y => y.MatrOpr).Distinct().Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var dbRec = await dbCtx
|
||||
.DbSetAnagGruppi
|
||||
.AsNoTracking()
|
||||
.Where(x => x.CodGruppo == updRec.CodGruppo)
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbRec != null)
|
||||
{
|
||||
dbRec.DescrGruppo = updRec.DescrGruppo;
|
||||
dbCtx.Entry(dbRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbCtx.DbSetAnagGruppi.AddAsync(updRec);
|
||||
}
|
||||
var numRes = await dbCtx.SaveChangesAsync();
|
||||
return numRes != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ListValuesModel>> AnagStatiCommAsync()
|
||||
{
|
||||
return await ListValuesFiltAsync("PODL", "StatoComm");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ListValuesModel>> AnagTipoArtLvAsync()
|
||||
{
|
||||
return await ListValuesFiltAsync("AnagArticoli", "Tipo");
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <inheritdoc />
|
||||
public async Task<List<string>> ArticleWithDossierAsync()
|
||||
{
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetDossiers
|
||||
.AsNoTracking()
|
||||
.Select(i => i.CodArticolo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> ArticoliCountAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetArticoli.CountAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> ArticoliCountSearchAsync(string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli.AsNoTracking();
|
||||
|
||||
if (tipoArt != "*")
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like(x.Tipo, tipoArt));
|
||||
}
|
||||
if (azienda != "*")
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like(x.Azienda, azienda));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchVal))
|
||||
{
|
||||
string pattern = $"%{searchVal}%";
|
||||
query = query.Where(x =>
|
||||
EF.Functions.Like(x.CodArticolo, pattern) ||
|
||||
EF.Functions.Like(x.DescArticolo, pattern) ||
|
||||
EF.Functions.Like(x.Disegno, pattern));
|
||||
}
|
||||
|
||||
return await query.OrderBy(x => x.CodArticolo).CountAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ArticoliDeleteRecordAsync(AnagArticoliModel currRec)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var currVal = await dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo == currRec.CodArticolo)
|
||||
.FirstOrDefaultAsync();
|
||||
if (currVal != null)
|
||||
{
|
||||
dbCtx.DbSetArticoli.Remove(currVal);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetByTipoAsync(string tipo, string azienda = "*")
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetArticoli
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Tipo.ToUpper() == tipo.ToUpper() && (azienda == "*" || x.Azienda.ToUpper() == azienda.ToUpper()))
|
||||
.OrderBy(x => x.CodArticolo)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetSearchAsync(int numRecord, string tipoArt = "*", string azienda = "*", string searchVal = "")
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
IQueryable<AnagArticoliModel> query = dbCtx.DbSetArticoli.AsNoTracking();
|
||||
|
||||
if (tipoArt != "*")
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like(x.Tipo, tipoArt));
|
||||
}
|
||||
if (azienda != "*")
|
||||
{
|
||||
query = query.Where(x => EF.Functions.Like(x.Azienda, azienda));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(searchVal))
|
||||
{
|
||||
string pattern = $"%{searchVal}%";
|
||||
query = query.Where(x =>
|
||||
EF.Functions.Like(x.CodArticolo, pattern) ||
|
||||
EF.Functions.Like(x.DescArticolo, pattern) ||
|
||||
EF.Functions.Like(x.Disegno, pattern));
|
||||
}
|
||||
|
||||
return await query.OrderBy(x => x.CodArticolo).Take(numRecord).ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUnusedAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetArticoli.FromSqlRaw("EXEC stp_ART_getNotUsed").AsNoTracking().ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagArticoliModel>> ArticoliGetUsedAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetArticoli.FromSqlRaw("EXEC stp_ART_getUsed").AsNoTracking().ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<AnagArticoliModel>> ArticoliInKitAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetArticoli.FromSqlRaw("EXEC stp_TempKIT_getArtChild").AsNoTracking().ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var currRec = await dbCtx.DbSetArticoli.FirstOrDefaultAsync(x => x.CodArticolo == editRec.CodArticolo);
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Disegno = editRec.Disegno;
|
||||
currRec.DescArticolo = editRec.DescArticolo;
|
||||
currRec.Tipo = editRec.Tipo;
|
||||
currRec.Azienda = editRec.Azienda;
|
||||
dbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<ListValuesModel>> ListValuesFiltAsync(string tabName, string fieldName)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetListValues
|
||||
.Where(x => x.TableName == tabName && x.FieldName == fieldName)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.ordinal)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
return await dbCtx.DbSetMacchine.AsNoTracking().OrderBy(x => x.IdxMacchina).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx.DbSetGrp2Oper
|
||||
.Where(g => g.MatrOpr == MatrOpr)
|
||||
.Join(dbCtx.DbSetGrp2Macc, g => g.CodGruppo, m => m.CodGruppo, (g, m) => m)
|
||||
.Distinct()
|
||||
.Join(dbCtx.DbSetMacchine, g => g.IdxMacchina, m => m.IdxMacchina, (g, m) => m)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
return await dbCtx.DbSetMacchine.AsNoTracking().OrderBy(x => x.IdxMacchina).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return await dbCtx.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine, g => g.IdxMacchina, m => m.IdxMacchina, (g, m) => m)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds)
|
||||
{
|
||||
if (missingIds == null || !missingIds.Any())
|
||||
return new Dictionary<int, int>();
|
||||
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => missingIds.Contains(x.IdxOdl))
|
||||
.ToDictionaryAsync(x => x.IdxOdl, x => x.IdxPromessa);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni da cache o DB
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
public async Task<Dictionary<string, string>> VocabolarioGetLangAsync(string lingua)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Lingua.ToLower() == lingua.ToLower())
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
// Proietto in dizionario
|
||||
return rawList
|
||||
.DistinctBy(t => t.Lemma, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(t => t.Lemma, t => t.Traduzione, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Anag
|
||||
{
|
||||
public abstract class BaseRepository : IBaseRepository
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected readonly IDbContextFactory<MoonProContext> _ctxFactory;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
protected BaseRepository(IDbContextFactory<MoonProContext> ctxFactory) => _ctxFactory = ctxFactory;
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Creazione dbcontext per singola transazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<MoonProContext> CreateContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Repository.Anag
|
||||
{
|
||||
public interface IAnagRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Stacca un nuovo counter x il tipo richiesto
|
||||
/// </summary>
|
||||
/// <param name="cntType">Tipo di contatore</param>
|
||||
/// <returns>Modello del contatore aggiornato</returns>
|
||||
Task<AnagCountersModel> AnagCountersGetNextAsync(string cntType);
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica EVENTI generalmente disponibile per OGNI macchina
|
||||
/// </summary>
|
||||
/// <param name="TableName">Nome Table x filtro (std: EvList)</param>
|
||||
/// <param name="FieldName">Nome Field x filtro (std: Common)</param>
|
||||
/// <returns>Lista di eventi generali</returns>
|
||||
Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync(string TableName = "EvList", string FieldName = "Common");
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Gruppi tipo Azienda
|
||||
/// </summary>
|
||||
/// <returns>Lista di modelli anagrafica gruppi</returns>
|
||||
Task<List<AnagGruppiModel>> AnagGruppiAziendeAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Delete record AnagraficaGruppi
|
||||
/// </summary>
|
||||
/// <param name="updRec">Record da eliminare</param>
|
||||
/// <returns>True se l'eliminazione è avvenuta</returns>
|
||||
Task<bool> AnagGruppiDeleteAsync(AnagGruppiModel updRec);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Gruppi tipo Fasi
|
||||
/// </summary>
|
||||
/// <returns>Lista di modelli anagrafica gruppi</returns>
|
||||
Task<List<AnagGruppiModel>> AnagGruppiFaseAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gruppi x tipo modalità Async
|
||||
/// </summary>
|
||||
/// <param name="tipoGruppo">Tipo di gruppo (es. REPARTO, FASE, AZIENDA)</param>
|
||||
/// <returns>Lista di modelli anagrafica gruppi</returns>
|
||||
Task<List<AnagGruppiModel>> AnagGruppiGetTipoAsync(string tipoGruppo);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Gruppi tipo REPARTO (x associazione Macchine-Operatori) in formato DTO con conteggi del numero record trovati
|
||||
/// </summary>
|
||||
/// <returns>Lista di DTO reparti con conteggio macchine e operatori</returns>
|
||||
Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Upsert record AnagraficaGruppi (solo codice/descrizione)
|
||||
/// </summary>
|
||||
/// <param name="updRec">Record da inserire o aggiornare</param>
|
||||
/// <returns>True se l'operazione è riuscita</returns>
|
||||
Task<bool> AnagGruppiUpsertAsync(AnagGruppiModel updRec);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x Stati commessa (es Yacht Baglietto)
|
||||
/// </summary>
|
||||
/// <returns>Lista di valori ammessi</returns>
|
||||
Task<List<ListValuesModel>> AnagStatiCommAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x Tipo articoli
|
||||
/// </summary>
|
||||
/// <returns>Lista di valori ammessi</returns>
|
||||
Task<List<ListValuesModel>> AnagTipoArtLvAsync();
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco codice articoli che abbiano dati Dossier
|
||||
/// </summary>
|
||||
/// <returns>Lista di codici articolo</returns>
|
||||
Task<List<string>> ArticleWithDossierAsync();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio num articoli Async
|
||||
/// </summary>
|
||||
/// <returns>Conteggio totale articoli</returns>
|
||||
Task<int> ArticoliCountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Conteggio articoli data condizione ricerca
|
||||
/// </summary>
|
||||
/// <param name="tipoArt">Tipo articolo</param>
|
||||
/// <param name="azienda">Azienda</param>
|
||||
/// <param name="searchVal">Valore di ricerca</param>
|
||||
/// <returns>Conteggio risultati ricerca</returns>
|
||||
Task<int> ArticoliCountSearchAsync(string tipoArt = "*", string azienda = "*", string searchVal = "");
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione Record Articolo
|
||||
/// </summary>
|
||||
/// <param name="currRec">Record da eliminare</param>
|
||||
/// <returns>True se eliminato</returns>
|
||||
Task<bool> ArticoliDeleteRecordAsync(AnagArticoliModel currRec);
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce elenco articoli dato tipo (es KIT)
|
||||
/// </summary>
|
||||
/// <param name="tipo">Tipo articolo (es. KIT)</param>
|
||||
/// <param name="azienda">Azienda (opzionale)</param>
|
||||
/// <returns>Lista di articoli per tipo</returns>
|
||||
Task<List<AnagArticoliModel>> ArticoliGetByTipoAsync(string tipo, string azienda = "*");
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord">Numero massimo di record</param>
|
||||
/// <param name="tipoArt">Tipo articolo</param>
|
||||
/// <param name="azienda">Azienda</param>
|
||||
/// <param name="searchVal">Valore di ricerca</param>
|
||||
/// <returns>Lista di articoli cercati</returns>
|
||||
Task<List<AnagArticoliModel>> ArticoliGetSearchAsync(int numRecord, string tipoArt = "*", string azienda = "*", string searchVal = "");
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli NON IMPIEGATI (da stored stp_ART_getUsed) Async
|
||||
/// </summary>
|
||||
/// <returns>Lista di articoli non impiegati</returns>
|
||||
Task<List<AnagArticoliModel>> ArticoliGetUnusedAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli IMPIEGATI (da stored stp_ART_getUsed) Async
|
||||
/// </summary>
|
||||
/// <returns>Lista di articoli impiegati</returns>
|
||||
Task<List<AnagArticoliModel>> ArticoliGetUsedAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Articoli che sono in KIT Child
|
||||
/// </summary>
|
||||
/// <returns>Lista di articoli in kit</returns>
|
||||
Task<List<AnagArticoliModel>> ArticoliInKitAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Update Record Articolo
|
||||
/// </summary>
|
||||
/// <param name="editRec">Record da aggiornare</param>
|
||||
/// <returns>True se aggiornato</returns>
|
||||
Task<bool> ArticoliUpdateRecord(AnagArticoliModel editRec);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x tabella/colonna Async
|
||||
/// </summary>
|
||||
/// <param name="tabName">Nome tabella</param>
|
||||
/// <param name="fieldName">Nome colonna</param>
|
||||
/// <returns>Lista di valori ammessi</returns>
|
||||
Task<List<ListValuesModel>> ListValuesFiltAsync(string tabName, string fieldName);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr">Matricola operatore</param>
|
||||
/// <returns>Lista di macchine</returns>
|
||||
Task<List<MacchineModel>> MacchineByMatrOperAsync(int MatrOpr);
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Macchine filtro x gruppo
|
||||
/// </summary>
|
||||
/// <param name="codGruppo">Codice gruppo</param>
|
||||
/// <returns>Lista di macchine</returns>
|
||||
Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo);
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario associazione ODL/PODL
|
||||
/// </summary>
|
||||
/// <param name="missingIds">Lista di ID mancanti</param>
|
||||
/// <returns>Dizionario di associazione</returns>
|
||||
Task<Dictionary<int, int>> PODL_getDictOdlPodlAsync(List<int> missingIds);
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dizionario traduzioni da cache o DB
|
||||
/// </summary>
|
||||
/// <param name="lingua">Codice lingua</param>
|
||||
/// <returns>Dizionario di traduzioni</returns>
|
||||
Task<Dictionary<string, string>> VocabolarioGetLangAsync(string lingua);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MP.Data.Repository.Anag
|
||||
{
|
||||
public interface IBaseRepository
|
||||
{
|
||||
//Task<DataLayerContext> CreateContextAsync();
|
||||
//Task<bool> SaveChangesAsync(DataLayerContext ctx);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,7 @@ namespace MP.Data.Repository.IOC
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
protected BaseRepository(IDbContextFactory<MoonProContext> ctxFactory)
|
||||
=> _ctxFactory = ctxFactory;
|
||||
protected BaseRepository(IDbContextFactory<MoonProContext> ctxFactory) => _ctxFactory = ctxFactory;
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
@@ -24,24 +23,8 @@ namespace MP.Data.Repository.IOC
|
||||
/// Creazione dbcontext per singola transazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<MoonProContext> CreateContextAsync()
|
||||
=> await _ctxFactory.CreateDbContextAsync();
|
||||
protected async Task<MoonProContext> CreateContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Salvataggio dati asincrono
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SaveChangesAsync(DataLayerContext ctx)
|
||||
=> await ctx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected readonly DataLayerContext _dbCtx;
|
||||
protected BaseRepository(DataLayerContext db) => _dbCtx = db;
|
||||
public async Task<bool> SaveChangesAsync() => await _dbCtx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,7 @@ namespace MP.Data.Repository.Utils
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
protected BaseRepository(IDbContextFactory<MoonPro_UtilsContext> ctxFactory)
|
||||
=> _ctxFactory = ctxFactory;
|
||||
protected BaseRepository(IDbContextFactory<MoonPro_UtilsContext> ctxFactory) => _ctxFactory = ctxFactory;
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
@@ -24,24 +23,9 @@ namespace MP.Data.Repository.Utils
|
||||
/// Creazione dbcontext per singola transazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<MoonPro_UtilsContext> CreateContextAsync()
|
||||
=> await _ctxFactory.CreateDbContextAsync();
|
||||
protected async Task<MoonPro_UtilsContext> CreateContextAsync() => await _ctxFactory.CreateDbContextAsync();
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Salvataggio dati asincrono
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SaveChangesAsync(DataLayerContext ctx)
|
||||
=> await ctx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
|
||||
#if false
|
||||
protected readonly DataLayerContext _dbCtx;
|
||||
protected BaseRepository(DataLayerContext db) => _dbCtx = db;
|
||||
public async Task<bool> SaveChangesAsync() => await _dbCtx.SaveChangesAsync() > 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user