Completo prima revisione repository x commenti
This commit is contained in:
@@ -15,6 +15,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<CounterModel>> GetAllAsync(int? yearRef = null)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
@@ -24,7 +25,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> GetNextAsync(int yearRef, string countName)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AddAsync(GenClassModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
@@ -18,6 +19,7 @@
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DeleteAsync(GenClassModel entity)
|
||||
{
|
||||
// Add validation for null entity
|
||||
@@ -33,12 +35,14 @@
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> CountChildrenAsync(string classCod)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetGenVal.CountAsync(x => x.ClassCod == classCod);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<GenClassModel>> GetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
@@ -48,12 +52,14 @@
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<GenClassModel?> GetByCodeAsync(string code)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetGenClass.FirstOrDefaultAsync(x => x.ClassCod == code);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> UpdateAsync(GenClassModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> AddAsync(GenValueModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
@@ -19,6 +20,7 @@
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> DeleteAsync(GenValueModel rec2del)
|
||||
{
|
||||
// Add validation for null entity
|
||||
@@ -66,12 +68,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<GenValueModel?> GetByIdAsync(int Id)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == Id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<GenValueModel>> GetFiltAsync(string codClass)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
@@ -81,6 +85,7 @@
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> MoveAsync(GenValueModel selRec, bool moveUp)
|
||||
{
|
||||
// Add validation for null entity
|
||||
@@ -139,11 +144,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<bool> UpdateAsync(GenValueModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
// Recuperiamo l'entità tracciata dal context
|
||||
var trackedEntity = dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == entity.GenValID);
|
||||
var trackedEntity = await dbCtx.DbSetGenVal.FirstOrDefaultAsync(x => x.GenValID == entity.GenValID);
|
||||
|
||||
if (trackedEntity != null)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per la gestione dei contatori.
|
||||
/// </summary>
|
||||
public interface ICounterRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Recupera l'elenco di tutti i contatori, opzionalmente filtrati per anno di riferimento.
|
||||
/// </summary>
|
||||
/// <param name="yearRef">L'anno di riferimento (opzionale).</param>
|
||||
/// <returns>L'elenco dei contatori.</returns>
|
||||
Task<List<CounterModel>> GetAllAsync(int? yearRef = null);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera il prossimo valore disponibile per un contatore specifico.
|
||||
/// </summary>
|
||||
/// <param name="yearRef">L'anno di riferimento.</param>
|
||||
/// <param name="countName">Il nome del contatore.</param>
|
||||
/// <returns>Il prossimo valore del contatore.</returns>
|
||||
Task<int> GetNextAsync(int yearRef, string countName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,49 @@
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per la gestione delle classi generiche.
|
||||
/// </summary>
|
||||
public interface IGenClassRepository : IBaseRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inserisce una nuova classe generica nel database.
|
||||
/// </summary>
|
||||
/// <param name="entity">La classe da inserire.</param>
|
||||
/// <returns>True se l'inserimento ha successo, false altrimenti.</returns>
|
||||
Task<bool> AddAsync(GenClassModel entity);
|
||||
|
||||
/// <summary>
|
||||
/// Conta i valori associati a una classe generica.
|
||||
/// </summary>
|
||||
/// <param name="classCod">Il codice della classe.</param>
|
||||
/// <returns>Il numero di valori associati alla classe.</returns>
|
||||
Task<int> CountChildrenAsync(string classCod);
|
||||
|
||||
/// <summary>
|
||||
/// Elimina una classe generica dal database.
|
||||
/// </summary>
|
||||
/// <param name="entity">La classe da eliminare.</param>
|
||||
/// <returns>True se l'eliminazione ha successo, false altrimenti.</returns>
|
||||
Task<bool> DeleteAsync(GenClassModel entity);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco di tutte le classi generiche con i valori associati.
|
||||
/// </summary>
|
||||
/// <returns>L'elenco di tutte le classi generiche.</returns>
|
||||
Task<List<GenClassModel>> GetAllAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Recupera una classe generica per il suo codice.
|
||||
/// </summary>
|
||||
/// <param name="code">Il codice della classe.</param>
|
||||
/// <returns>La classe corrispondente, o null se non esiste.</returns>
|
||||
Task<GenClassModel?> GetByCodeAsync(string code);
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna una classe generica esistente nel database.
|
||||
/// </summary>
|
||||
/// <param name="entity">La classe aggiornata.</param>
|
||||
/// <returns>True se l'aggiornamento ha successo, false altrimenti.</returns>
|
||||
Task<bool> UpdateAsync(GenClassModel entity);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,51 @@
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per la gestione dei valori generici.
|
||||
/// </summary>
|
||||
public interface IGenValRepository : IBaseRepository
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inserisce un nuovo valore generico nel database.
|
||||
/// </summary>
|
||||
/// <param name="entity">Il valore da inserire.</param>
|
||||
/// <returns>True se l'inserimento ha successo, false altrimenti.</returns>
|
||||
Task<bool> AddAsync(GenValueModel entity);
|
||||
|
||||
/// <summary>
|
||||
/// Elimina un valore generico dal database e adegua gli indici successivi.
|
||||
/// </summary>
|
||||
/// <param name="entity">Il valore da eliminare.</param>
|
||||
/// <returns>True se l'eliminazione ha successo, false altrimenti.</returns>
|
||||
Task<bool> DeleteAsync(GenValueModel entity);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera un valore generico per il suo identificatore.
|
||||
/// </summary>
|
||||
/// <param name="Id">L'identificatore del valore.</param>
|
||||
/// <returns>Il valore corrispondente, o null se non esiste.</returns>
|
||||
Task<GenValueModel?> GetByIdAsync(int Id);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco dei valori generici per una classe specifica.
|
||||
/// </summary>
|
||||
/// <param name="codClass">Il codice della classe.</param>
|
||||
/// <returns>L'elenco dei valori associati alla classe.</returns>
|
||||
Task<List<GenValueModel>> GetFiltAsync(string codClass);
|
||||
|
||||
/// <summary>
|
||||
/// Sposta su o giù un valore generico all'interno della sua classe.
|
||||
/// </summary>
|
||||
/// <param name="selRec">Il valore da spostare.</param>
|
||||
/// <param name="moveUp">Se true, sposta il valore verso l'alto; altrimenti verso il basso.</param>
|
||||
/// <returns>True se lo spostamento ha successo, false altrimenti.</returns>
|
||||
Task<bool> MoveAsync(GenValueModel selRec, bool moveUp);
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorna un valore generico esistente nel database.
|
||||
/// </summary>
|
||||
/// <param name="entity">Il valore aggiornato.</param>
|
||||
/// <returns>True se l'aggiornamento ha successo, false altrimenti.</returns>
|
||||
Task<bool> UpdateAsync(GenValueModel entity);
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Interfaccia per la gestione dei tag.
|
||||
/// </summary>
|
||||
public interface ITagRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Recupera l'elenco di tutti i tag.
|
||||
/// </summary>
|
||||
/// <returns>L'elenco di tutti i tag.</returns>
|
||||
Task<List<TagsModel>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<TagsModel>> GetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
|
||||
Reference in New Issue
Block a user