コード例 #1
0
        public void FilterModified <T>(T modified) where T : class
        {
            ITenantOwned tenantOwned = modified as ITenantOwned;

            if (tenantOwned != null)
            {
                Guid?tenantId = tenantContext.Tenant?.Id;
                if (tenantOwned.TenantId != null && tenantId != null &&
                    tenantOwned.TenantId != tenantId)
                {
                    throw new InvalidOperationException(
                              $"Forbidden to modify {typeof(T).FullName} entity for tenant ID {tenantOwned.TenantId.Value} from context of tenant ID {tenantId.Value}");
                }
            }
        }
コード例 #2
0
        public void FilterModified <T>(T modified) where T : class
        {
            ITenantOwned tenantOwned = modified as ITenantOwned;

            if (tenantOwned != null)
            {
                Guid?tenantId = tenantContext.Value.Tenant?.Id;
                if (tenantOwned.TenantId != null &&
                    (!NullTenantCanAccessOtherTenantsData || tenantId != null) &&
                    tenantOwned.TenantId != tenantId)
                {
                    throw new InvalidOperationException(
                              $"Forbidden to modify {modified} entity for tenant ID {tenantOwned.TenantId.Value} from context of tenant ID {tenantId}");
                }
            }
        }
コード例 #3
0
        public void FilterDeleted <T>(T deleted) where T : class
        {
            ITenantOwned tenantOwned = deleted as ITenantOwned;

            if (tenantOwned != null)
            {
                Guid?tenantId = tenantContext.Tenant?.Id;
                if (tenantOwned.TenantId != null &&
                    (!NullTenantCanAccessOtherTenantsData || tenantId != null) &&
                    tenantOwned.TenantId != tenantId)
                {
                    throw new InvalidOperationException(
                              $"Forbidden to delete {typeof(T).FullName} entity for tenant ID {tenantOwned.TenantId.Value} from context of tenant ID {tenantId.Value}");
                }
            }
        }
コード例 #4
0
        public T FilterResult <T>(T result) where T : class
        {
            ITenantOwned tenantOwned = result as ITenantOwned;

            if (tenantOwned != null)
            {
                Guid?tenantId = tenantContext.Tenant?.Id;
                if (tenantOwned.TenantId != null && tenantId != null &&
                    tenantOwned.TenantId != tenantId)
                {
                    return(null);
                }
            }

            return(result);
        }
コード例 #5
0
        public T FilterResult <T>(T result) where T : class
        {
            ITenantOwned tenantOwned = result as ITenantOwned;

            if (tenantOwned != null)
            {
                Guid?tenantId = tenantContext.Value.Tenant?.Id;
                if (tenantOwned.TenantId != null &&
                    (!NullTenantCanAccessOtherTenantsData || tenantId != null) &&
                    tenantOwned.TenantId != tenantId)
                {
                    return(null);
                }
            }

            return(result);
        }