.Net Core 2.2 ASPNetZero 7.0.0
In our application one user from one tenant account can request something other tenant account and second tenant can approve something: so when SaveChanges is called for record which was created by tenant 1 updated by tenant 2 system is not saving lastmodifieduserid: for this I have override the function of GetAuditUserId in DbContext file but still its not saving modified user's Id.
Is there anything that I am doing wrong here?
protected override long? GetAuditUserId()
{
if (AbpSession.UserId.HasValue &&
CurrentUnitOfWorkProvider != null &&
CurrentUnitOfWorkProvider.Current != null)
{
return AbpSession.UserId;
}
return null;
}
2 Answer(s)
-
0
I think it is not the place you are looking for. Aspnetboilerplate sets
LastModifierUserId
in https://github.com/aspnetboilerplate/aspnetboilerplate/blob/e711cc08b81ba39bb04839b8af432574413fc2cd/src/Abp/Domain/Entities/Auditing/EntityAuditingHelper.cs#L107-L113. As you see, yourMultiTenancyHelper.IsTenantEntity
most probably returns false. You may need to override https://github.com/aspnetboilerplate/aspnetboilerplate/blob/e711cc08b81ba39bb04839b8af432574413fc2cd/src/Abp.EntityFrameworkCore/EntityFrameworkCore/AbpDbContext.cs#L467-L473 with your own logic. -
0
Hello @musa.demir,
After overriding SetModificationAuditProperties and GetAuditUserId functions its working fine and setting the correct modified properties. Thank you!