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}"); } } }
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}"); } } }
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}"); } } }
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); }
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); }