Base solution for your next web application
Open Closed

Add a field in notification data (& retrieve it) #5988


User avatar
0
sbenfares created

Hi,

I would like to add a custom "Link" field in a User Notification.

I've created a class MessageAndLinkNotificationData :

[Serializable]
    public class MessageAndLinkNotificationData : MessageNotificationData
    {
        public string Link { get; set; }

        public MessageAndLinkNotificationData(string message, string link) : base(message)
        {
            Link = link;
        }
    }

When i try to retrieve the data in my controller :

var dto = await _userNotificationManager.GetUserNotificationAsync(AbpSession.TenantId, userNotificationId);
var model = new MessageDetailViewModel(dto.Notification.Data.Properties["Message"].ToString(), 
                                                    dto.Notification.Data.Properties["Link"].ToString(), 
                                                    dto.Notification.CreationTime);

I have an error : ** 'NotificationData' does not contain a definition for 'Link' and no accessible extension method 'Link' accepting a first argument of type 'NotificationData' could be found **

What is the best practise to customise User Notification ?

Thanks

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

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

    Hi @sbenfares

    Ifyou want your notification to be clickable, you can check current implementation of Download collected data feature.

    Here is the implementation details https://github.com/aspnetzero/aspnet-zero-core/issues/1208

    It generates a clickable notificaiton.

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

    Thanks it helped !

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