Browse Source

Entity has tenant id property.

pull/1137/head
mehmetuken 7 years ago
parent
commit
1bdddc7d63
  1. 2
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs
  2. 2
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs
  3. 10
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs

2
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs

@ -91,7 +91,7 @@ namespace Volo.Abp.Application.Services
var entity = MapToEntity(input); var entity = MapToEntity(input);
if(entity is IMultiTenant) if(entity is IMultiTenant && !HasTenantIdProperty(entity))
{ {
TryToSetTenantId(entity); TryToSetTenantId(entity);
} }

2
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs

@ -88,7 +88,7 @@ namespace Volo.Abp.Application.Services
var entity = MapToEntity(input); var entity = MapToEntity(input);
if(entity is IMultiTenant) if(entity is IMultiTenant && !HasTenantIdProperty(entity))
{ {
TryToSetTenantId(entity); TryToSetTenantId(entity);
} }

10
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppServiceBase.cs

@ -154,11 +154,6 @@ namespace Volo.Abp.Application.Services
protected virtual void TryToSetTenantId(TEntity entity) protected virtual void TryToSetTenantId(TEntity entity)
{ {
if (entity is IMultiTenant tenantEntity && tenantEntity.TenantId.HasValue)
{
return;
}
var tenantId = CurrentTenant.Id; var tenantId = CurrentTenant.Id;
if (!tenantId.HasValue) if (!tenantId.HasValue)
@ -173,5 +168,10 @@ namespace Volo.Abp.Application.Services
propertyInfo.SetValue(entity, tenantId, null); propertyInfo.SetValue(entity, tenantId, null);
} }
} }
protected virtual bool HasTenantIdProperty(TEntity entity)
{
return entity.GetType().GetProperty(nameof(IMultiTenant.TenantId)) != null;
}
} }
} }

Loading…
Cancel
Save