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 !!

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Duplicate of #4206@1869b60c-666b-42bd-b275-2b83d023cc6f

    Save changes before publishing a notification.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    simedbn created

    Hello,

    Thank you @aaron :D

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)