Aggiunta ItemGroup Repo/Serv
This commit is contained in:
@@ -140,6 +140,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#if true
|
||||
/// <summary>
|
||||
/// Elenco completo ItemGroup gestiti
|
||||
/// </summary>
|
||||
@@ -187,6 +188,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal async Task<bool> OffersCheckExpired()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Items;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Items
|
||||
{
|
||||
public interface IItemGroupRepository
|
||||
{
|
||||
Task<List<ItemGroupModel>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Items;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Repository.Items
|
||||
{
|
||||
public class ItemGroupRepository : BaseRepository, IItemGroupRepository
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ItemGroupRepository(IDbContextFactory<DataLayerContext> ctxFactory) : base(ctxFactory)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<List<ItemGroupModel>> GetAllAsync()
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
return await dbCtx.DbSetItemGroup
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ namespace EgwCoreLib.Lux.Data.Services.Config
|
||||
|
||||
public async Task<List<EnvirParamModel>> GetAllAsync()
|
||||
{
|
||||
// Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking
|
||||
return await TraceAsync($"{_className}.GetAll", async (activity) =>
|
||||
{
|
||||
return await GetOrSetCacheAsync(
|
||||
|
||||
@@ -167,6 +167,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if true
|
||||
/// <summary>
|
||||
/// Elenco completo ItemGroup gestiti
|
||||
/// </summary>
|
||||
@@ -199,6 +200,7 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Verifica offerte scadute, con update sul DB
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Items;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services.Items
|
||||
{
|
||||
public interface IItemGroupService
|
||||
{
|
||||
Task<List<ItemGroupModel>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using EgwCoreLib.Lux.Data.DbModel.Items;
|
||||
using EgwCoreLib.Lux.Data.Repository.Items;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace EgwCoreLib.Lux.Data.Services.Items
|
||||
{
|
||||
public class ItemGroupService : BaseServ, IItemGroupService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ItemGroupService(
|
||||
IConfiguration config,
|
||||
IConnectionMultiplexer redis,
|
||||
IItemGroupRepository repo) : base(config, redis)
|
||||
{
|
||||
_className = "ItemGroup";
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<List<ItemGroupModel>> GetAllAsync()
|
||||
{
|
||||
return await TraceAsync($"{_className}.GetAll", async (activity) =>
|
||||
{
|
||||
return await GetOrSetCacheAsync(
|
||||
$"{_redisBaseKey}:{_className}:ALL",
|
||||
async () => await _repo.GetAllAsync(),
|
||||
UltraLongCache
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly string _className;
|
||||
private readonly IItemGroupRepository _repo;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user