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
parent
commit
6f35b53492
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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. 7
      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);
if(entity is IMultiTenant)
if(entity is IMultiTenant && !HasTenantIdProperty(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);
if(entity is IMultiTenant)
if(entity is IMultiTenant && !HasTenantIdProperty(entity))
{
TryToSetTenantId(entity);
}

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

@ -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;
}
}
}

Loading…
Cancel
Save