// EN: Adapter that bridges API-layer ITenantProvider to Infrastructure-layer IInventoryTenantProvider.
// VI: Adapter kết nối ITenantProvider tầng API đến IInventoryTenantProvider tầng Infrastructure.

using InventoryService.Infrastructure;

namespace InventoryService.API.Infrastructure.Tenant;

/// <summary>
/// EN: Adapts the API-layer ITenantProvider to the Infrastructure IInventoryTenantProvider interface.
/// VI: Chuyển đổi ITenantProvider tầng API sang interface IInventoryTenantProvider tầng Infrastructure.
/// </summary>
public class InventoryTenantProviderAdapter : IInventoryTenantProvider
{
    private readonly ITenantProvider _tenantProvider;

    public InventoryTenantProviderAdapter(ITenantProvider tenantProvider)
    {
        _tenantProvider = tenantProvider ?? throw new ArgumentNullException(nameof(tenantProvider));
    }

    public Guid? GetCurrentShopId() => _tenantProvider.GetCurrentShopId();

    public bool ShouldBypassTenantFilter() =>
        _tenantProvider.IsServiceCall() || _tenantProvider.IsAdmin();
}
