50 lines
2.9 KiB
C#
50 lines
2.9 KiB
C#
using Tiku.Application.Commerce;
|
|
using Tiku.Application.Jobs;
|
|
using Tiku.Application.Learning;
|
|
using Tiku.Application.Security;
|
|
using Tiku.Application.Tenancy;
|
|
using Tiku.Infrastructure.Persistence;
|
|
|
|
namespace Tiku.Infrastructure.Commerce;
|
|
|
|
internal sealed record CommerceAdministrationDependencies(
|
|
ICommercePersistence CommercePersistence,
|
|
IPointsPersistence PointsPersistence,
|
|
ICatalogPersistence CatalogPersistence,
|
|
IIdentityPersistence IdentityPersistence,
|
|
ITenancyPersistence TenancyPersistence,
|
|
IJobsOperationsPersistence JobsOperationsPersistence,
|
|
ILearningAccessPersistence LearningAccessPersistence,
|
|
ILearningAccessService LearningAccessService,
|
|
ITenantSecretProtector TenantSecretProtector,
|
|
ITenantExternalProviderConfigService ProviderConfigService,
|
|
ICurrentAccessContext CurrentAccessContext,
|
|
IBackgroundJobQueue BackgroundJobQueue,
|
|
IBackgroundJobOperations BackgroundJobOperations);
|
|
|
|
internal abstract partial class CommerceAdministrationServiceBase(CommerceAdministrationDependencies dependencies)
|
|
{
|
|
protected ICommercePersistence commercePersistence { get; } = dependencies.CommercePersistence;
|
|
protected IPointsPersistence pointsPersistence { get; } = dependencies.PointsPersistence;
|
|
protected ICatalogPersistence catalogPersistence { get; } = dependencies.CatalogPersistence;
|
|
protected IIdentityPersistence identityPersistence { get; } = dependencies.IdentityPersistence;
|
|
protected ITenancyPersistence tenancyPersistence { get; } = dependencies.TenancyPersistence;
|
|
protected IJobsOperationsPersistence jobsOperationsPersistence { get; } = dependencies.JobsOperationsPersistence;
|
|
protected ILearningAccessPersistence learningAccessPersistence { get; } = dependencies.LearningAccessPersistence;
|
|
protected ILearningAccessService learningAccessService { get; } = dependencies.LearningAccessService;
|
|
protected IModulePersistence unitOfWork { get; } = dependencies.CommercePersistence;
|
|
protected ITenantSecretProtector tenantSecretProtector { get; } = dependencies.TenantSecretProtector;
|
|
protected ITenantExternalProviderConfigService providerConfigService { get; } = dependencies.ProviderConfigService;
|
|
protected ICurrentAccessContext currentAccessContext { get; } = dependencies.CurrentAccessContext;
|
|
protected IBackgroundJobQueue backgroundJobQueue { get; } = dependencies.BackgroundJobQueue;
|
|
protected IBackgroundJobOperations backgroundJobOperations { get; } = dependencies.BackgroundJobOperations;
|
|
private readonly HashSet<(Guid TenantId, Guid UserId)> learningAccessInvalidations = [];
|
|
|
|
protected async Task FlushLearningAccessInvalidationsAsync(CancellationToken cancellationToken)
|
|
{
|
|
await Task.WhenAll(learningAccessInvalidations.Select(item =>
|
|
learningAccessService.InvalidateAsync(item.TenantId, item.UserId, cancellationToken)));
|
|
learningAccessInvalidations.Clear();
|
|
}
|
|
}
|