Browse Source
Merge pull request #1137 from mehmetuken/patch-2
Check entity has a tenant id value.
pull/1140/head
Halil İbrahim Kalkan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
8 additions and
3 deletions
-
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs
-
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs
-
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs
|
|
|
@ -91,7 +91,7 @@ namespace Volo.Abp.Application.Services |
|
|
|
|
|
|
|
var entity = MapToEntity(input); |
|
|
|
|
|
|
|
if(entity is IMultiTenant) |
|
|
|
if(entity is IMultiTenant && !HasTenantIdProperty(entity)) |
|
|
|
{ |
|
|
|
TryToSetTenantId(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ namespace Volo.Abp.Application.Services |
|
|
|
|
|
|
|
var entity = MapToEntity(input); |
|
|
|
|
|
|
|
if(entity is IMultiTenant) |
|
|
|
if(entity is IMultiTenant && !HasTenantIdProperty(entity)) |
|
|
|
{ |
|
|
|
TryToSetTenantId(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ namespace Volo.Abp.Application.Services |
|
|
|
{ |
|
|
|
var tenantId = CurrentTenant.Id; |
|
|
|
|
|
|
|
if (tenantId == null) |
|
|
|
if (!tenantId.HasValue) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -168,5 +168,10 @@ namespace Volo.Abp.Application.Services |
|
|
|
propertyInfo.SetValue(entity, tenantId, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual bool HasTenantIdProperty(TEntity entity) |
|
|
|
{ |
|
|
|
return entity.GetType().GetProperty(nameof(IMultiTenant.TenantId)) != null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|