Files

62 lines
1.7 KiB
C#

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
/// <inheritdoc />
public async Task<bool> AddMissingAsync(List<BomItemDTO> bomList)
{
return await TraceAsync($"{_className}.AddMissing", async (activity) =>
{
string operation = "AddMissing";
bool success = await _repo.AddMissingAsync(bomList);
activity?.SetTag("db.operation", operation);
if (success)
{
await ClearCacheAsync($"{_redisBaseKey}:{_className}:*");
}
return success;
});
}
/// <inheritdoc />
public async Task<List<ItemGroupModel>> GetAllAsync()
{
return await TraceAsync($"{_className}.GetAllAsync", 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
}
}