using JetBrains.Annotations; using Volo.Abp.Settings; namespace NPin.Framework.SettingManagement.Domain.Provider.Extensions; public static class TenantSettingManagerExtensions { public static Task GetOrNullForTenantAsync(this ISettingManager settingManager, [NotNull] string name, Guid tenantId, bool fallback = true) { return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback); } public static Task GetOrNullForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) { return settingManager.GetOrNullAsync(name, TenantSettingValueProvider.ProviderName, null, fallback); } public static Task> GetAllForTenantAsync(this ISettingManager settingManager, Guid tenantId, bool fallback = true) { return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, tenantId.ToString(), fallback); } public static Task> GetAllForCurrentTenantAsync(this ISettingManager settingManager, bool fallback = true) { return settingManager.GetAllAsync(TenantSettingValueProvider.ProviderName, null, fallback); } public static Task SetForTenantAsync(this ISettingManager settingManager, Guid tenantId, [NotNull] string name, string? value, bool forceToSet = false) { return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, tenantId.ToString(), forceToSet); } public static Task SetForCurrentTenantAsync(this ISettingManager settingManager, [NotNull] string name, string? value, bool forceToSet = false) { return settingManager.SetAsync(name, value, TenantSettingValueProvider.ProviderName, null, forceToSet); } public static Task SetForTenantOrGlobalAsync(this ISettingManager settingManager, Guid? tenantId, [NotNull] string name, string? value, bool forceToSet = false) { return tenantId.HasValue ? settingManager.SetForTenantAsync(tenantId.Value, name, value, forceToSet) : settingManager.SetGlobalAsync(name, value); } }