Esempio n. 1
0
    protected virtual TenantCacheItem GetCacheItem(Guid?id, string name)
    {
        var cacheKey = CalculateCacheKey(id, name);

        var cacheItem = Cache.Get(cacheKey, considerUow: true);

        if (cacheItem != null)
        {
            return(cacheItem);
        }

        if (id.HasValue)
        {
            using (CurrentTenant.Change(null)) //TODO: No need this if we can implement to define host side (or tenant-independent) entities!
            {
                var tenant = TenantRepository.FindById(id.Value);
                return(SetCache(cacheKey, tenant));
            }
        }

        if (!name.IsNullOrWhiteSpace())
        {
            using (CurrentTenant.Change(null)) //TODO: No need this if we can implement to define host side (or tenant-independent) entities!
            {
                var tenant = TenantRepository.FindByName(name);
                return(SetCache(cacheKey, tenant));
            }
        }

        throw new AbpException("Both id and name can't be invalid.");
    }
Esempio n. 2
0
        public virtual TenantConfiguration Find(Guid id)
        {
            using (CurrentTenant.Change(null)) {
                var tenant = TenantRepository.FindById(id);
                if (tenant == null)
                {
                    return(null);
                }

                return(ObjectMapper.Map <Tenant, TenantConfiguration> (tenant));
            }
        }
Esempio n. 3
0
        public virtual TenantConfiguration Find(Guid id)
        {
            using (CurrentTenant.Change(null)) //TODO: No need this if we can implement to define host side (or tenant-independent) entities!
            {
                var tenant = TenantRepository.FindById(id);
                if (tenant == null)
                {
                    return(null);
                }

                return(ObjectMapper.Map <Tenant, TenantConfiguration>(tenant));
            }
        }