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


2 Answer(s)