TenantStore.cs 855 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Abp.MultiTenancy;
  2. namespace IwbZero.MultiTenancy
  3. {
  4. public class TenantStore : ITenantStore
  5. {
  6. private readonly ITenantCache _tenantCache;
  7. public TenantStore(ITenantCache tenantCache)
  8. {
  9. _tenantCache = tenantCache;
  10. }
  11. public TenantInfo Find(int tenantId)
  12. {
  13. var tenant = _tenantCache.GetOrNull(tenantId);
  14. if (tenant == null)
  15. {
  16. return null;
  17. }
  18. return new TenantInfo(tenant.Id, tenant.TenancyName);
  19. }
  20. public TenantInfo Find(string tenancyName)
  21. {
  22. var tenant = _tenantCache.GetOrNull(tenancyName);
  23. if (tenant == null)
  24. {
  25. return null;
  26. }
  27. return new TenantInfo(tenant.Id, tenant.TenancyName);
  28. }
  29. }
  30. }