Base solution for your next web application
Open Closed

Can not set TenantId to 0 : When i try to send notification #4553


User avatar
0
simedbn created

Hello,

I have an error when i want to send a notification :

ERROR 2018-01-22 18:58:10,334 [20   ] Mvc.ExceptionHandling.AbpExceptionFilter - Can not set TenantId to 0 for IMustHaveTenant entities!
Abp.AbpException: Can not set TenantId to 0 for IMustHaveTenant entities!
   ࡁbp.EntityFrameworkCore.AbpDbContext.CheckAndSetMustHaveTenantIdProperty(Object entityAsObj)
   ࡁbp.EntityFrameworkCore.AbpDbContext.ApplyAbpConceptsForAddedEntity(EntityEntry entry, Nullable`1 userId, EntityChangeReport changeReport)
   ࡁbp.EntityFrameworkCore.AbpDbContext.ApplyAbpConcepts(EntityEntry entry, Nullable`1 userId, EntityChangeReport changeReport)
   ࡁbp.EntityFrameworkCore.AbpDbContext.ApplyAbpConcepts()
public async Task SubscriptionAddedToMemberAsync(Member member, User user)
        {
            var notificationData = new LocalizableMessageNotificationData(
              new LocalizableString(
                  "NewMemberSubscriptionAddedNotificationMessage",
                  MyAppConsts.LocalizationSourceName
                  )
              );

            notificationData["memberName"] = member.FirstName;
            notificationData["userName"] = user.FullName;

            await _notificationPublisher.PublishAsync(
                AppNotificationNames.NewMemberSubscriptionAdded,
                notificationData,
                severity: NotificationSeverity.Warn,
                excludedUserIds: new[] { user.ToUserIdentifier() });

        }

But not On :

public async Task MemberDeletedAsync(Member member, User user)
        {
            var notificationData = new LocalizableMessageNotificationData(
               new LocalizableString(
                   "MemberDeletedNotificationMessage",
                   MyAppConsts.LocalizationSourceName
                   )
               );

            notificationData["memberName"] = $"{member.FirstName} {member.LastName}";
            notificationData["userName"] = user.FullName;

            await _notificationPublisher.PublishAsync(
                AppNotificationNames.MemberDeleted,
                notificationData,
                severity: NotificationSeverity.Warn,
                excludedUserIds: new[] { user.ToUserIdentifier() });
        }

Those methods are called from AppServices

Any Idea please !!


2 Answer(s)