Class NotificationsController
Provides the methods to work with Notifications, NotificationTypes, NotificationTypeActions and NotificationActions.
Inheritance
Implements
Inherited Members
Namespace: DotNetNuke.Services.Social.Notifications
Assembly: DotNetNuke.dll
Syntax
public class NotificationsController : ServiceLocator<INotificationsController, NotificationsController>, INotificationsController
Constructors
| Improve this Doc View SourceNotificationsController()
Initializes a new instance of the NotificationsController class. Default constructor.
Declaration
public NotificationsController()
NotificationsController(IDataService, IDataService)
Initializes a new instance of the NotificationsController class. Constructor from specifict data service.
Declaration
public NotificationsController(IDataService dataService, IDataService messagingDataService)
Parameters
Type | Name | Description |
---|---|---|
IDataService | dataService | Class with methods to do CRUD in database for the entities of types NotificationType, NotificationTypeAction and Notification. |
IDataService | messagingDataService | Class with methods to do CRUD in database for the entities of types Message, MessageRecipient and MessageAttachment and to interact with the stored procedures regarding messaging. |
Methods
| Improve this Doc View SourceCountNotifications(Int32, Int32)
Counts the notifications sent to the provided user in the specified portal.
Declaration
public virtual int CountNotifications(int userId, int portalId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | The user identifier. |
System.Int32 | portalId | The portal identifier. |
Returns
Type | Description |
---|---|
System.Int32 | The number of notifications sent to the provided user in the specified portal. |
CreateNotificationType(NotificationType)
Creates a new notification type.
Declaration
public void CreateNotificationType(NotificationType notificationType)
Parameters
Type | Name | Description |
---|---|---|
NotificationType | notificationType |
DeleteAllNotificationRecipients(Int32)
Deletes all NotificationRecipient for the NotificationId.
Declaration
public virtual void DeleteAllNotificationRecipients(int notificationId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The notification identifier. |
Remarks
It also deletes the notification.
DeleteNotification(Int32)
Deletes an existing notification.
Declaration
public virtual void DeleteNotification(int notificationId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The notification identifier. |
Remarks
It does not delete NotificationRecipient.
DeleteNotificationRecipient(Int32, Int32)
Deletes an individual notification recipient.
Declaration
public virtual void DeleteNotificationRecipient(int notificationId, int userId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The notification identifier. |
System.Int32 | userId | The user identifier. |
Remarks
It also deletes the notification if there are no more recipients.
DeleteNotificationRecipient(Int32, String, Int32)
Deletes an individual notification recipient based on NotificationTypeId, Context and UserId.
Declaration
public virtual void DeleteNotificationRecipient(int notificationTypeId, string context, int userId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | Id of the notification type. |
System.String | context | Context set by creator of the notification. |
System.Int32 | userId | The user identifier. |
Remarks
It also deletes the notification if there are no more recipients.
DeleteNotificationType(Int32)
Deletes an existing notification type.
Declaration
public virtual void DeleteNotificationType(int notificationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | The notification type identifier. |
DeleteNotificationTypeAction(Int32)
Deletes an existing notification type action.
Declaration
public virtual void DeleteNotificationTypeAction(int notificationTypeActionId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeActionId | The notification type action identifier. |
DeleteUserNotifications(UserInfo)
Deletes all user notifications in a specific portal.
Declaration
public int DeleteUserNotifications(UserInfo user)
Parameters
Type | Name | Description |
---|---|---|
UserInfo | user | The user to delete notifications for. |
Returns
Type | Description |
---|---|
System.Int32 | Number of deleted notifications. |
GetFactory()
Gets the service locator factory.
Declaration
protected override Func<INotificationsController> GetFactory()
Returns
Type | Description |
---|---|
Func<INotificationsController> | A factory function. |
Overrides
GetNotification(Int32)
Get a Notification.
Declaration
public Notification GetNotification(int notificationId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The notificationId. |
Returns
Type | Description |
---|---|
Notification | A notification. |
GetNotificationByContext(Int32, String)
Get a Notification by NotificationTypeId and Context.
Declaration
public virtual IList<Notification> GetNotificationByContext(int notificationTypeId, string context)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | Id of the notification type. |
System.String | context | Context set by creator of the notification. |
Returns
Type | Description |
---|---|
IList<Notification> | The filtered list of notifications sent to the provided user in the specified portal. |
GetNotifications(Int32, Int32, Int32, Int32)
Gets a list of notifications sent to the provided user in the specified portal.
Declaration
public virtual IList<Notification> GetNotifications(int userId, int portalId, int afterNotificationId, int numberOfRecords)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | The user identifier. |
System.Int32 | portalId | The portal identifier. |
System.Int32 | afterNotificationId | The notification identifier of the last notification displayed. Use -1 to start from the beggining of the list. |
System.Int32 | numberOfRecords | The number of results to retrieve. |
Returns
Type | Description |
---|---|
IList<Notification> | The filtered list of notifications sent to the provided user in the specified portal. |
GetNotificationType(Int32)
Gets a notification type by identifier.
Declaration
public virtual NotificationType GetNotificationType(int notificationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | The notification type identifier. |
Returns
Type | Description |
---|---|
NotificationType | The notification type with the provided identifier. |
GetNotificationType(String)
Gets a notification type by name.
Declaration
public virtual NotificationType GetNotificationType(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The notification type name. |
Returns
Type | Description |
---|---|
NotificationType | The notification type with the provided name. |
GetNotificationTypeAction(Int32, String)
Gets a notification type action by notification type and name.
Declaration
public virtual NotificationTypeAction GetNotificationTypeAction(int notificationTypeId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | The notification type identifier. |
System.String | name | The notification type action name. |
Returns
Type | Description |
---|---|
NotificationTypeAction | The notification type action with the provided notification type and name. |
GetNotificationTypeAction(Int32)
Gets a notification type action by identifier.
Declaration
public virtual NotificationTypeAction GetNotificationTypeAction(int notificationTypeActionId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeActionId | The notification type action identifier. |
Returns
Type | Description |
---|---|
NotificationTypeAction | The notification type action with the provided identifier. |
GetNotificationTypeActions(Int32)
Gets the list of notification type actions for the provided notification type.
Declaration
public virtual IList<NotificationTypeAction> GetNotificationTypeActions(int notificationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationTypeId | The notification type identifier. |
Returns
Type | Description |
---|---|
IList<NotificationTypeAction> | An ordered list of notification type actions for the provided notification type. |
GetToasts(UserInfo)
Get a list of Toasts that have not been delivered yet.
Declaration
public IList<Notification> GetToasts(UserInfo userInfo)
Parameters
Type | Name | Description |
---|---|---|
UserInfo | userInfo | UserInfo object. |
Returns
Type | Description |
---|---|
IList<Notification> | List of Undelivered Toasts for the user specific to the portal. |
IsToastPending(Int32)
Is there a Toast that needs to be sent for a Notification.
Declaration
public bool IsToastPending(int notificationId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The Notification Id. |
Returns
Type | Description |
---|---|
System.Boolean | True if Toast needs to be sent. False otherwise. |
MarkReadyForToast(Notification, UserInfo)
Mark a Toast ready for sending.
Declaration
public void MarkReadyForToast(Notification notification, UserInfo userInfo)
Parameters
Type | Name | Description |
---|---|---|
Notification | notification | The notification Object. |
UserInfo | userInfo | The Recipient User Info Object. |
MarkReadyForToast(Notification, Int32)
Provides the methods to work with Notifications, NotificationTypes, NotificationTypeActions and NotificationActions.
Declaration
public void MarkReadyForToast(Notification notification, int userId)
Parameters
Type | Name | Description |
---|---|---|
Notification | notification | |
System.Int32 | userId |
MarkToastSent(Int32, Int32)
Mark Toast being already sent.
Declaration
public void MarkToastSent(int notificationId, int userId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | notificationId | The notification Id. |
System.Int32 | userId | The Recipient User Id. |
SendNotification(Notification, Int32, IList<RoleInfo>, IList<UserInfo>)
Creates a new notification and sets is sender as the portal administrator.
Declaration
public virtual void SendNotification(Notification notification, int portalId, IList<RoleInfo> roles, IList<UserInfo> users)
Parameters
Type | Name | Description |
---|---|---|
Notification | notification | The notification. |
System.Int32 | portalId | The portalId. |
IList<RoleInfo> | roles | The list of roles to send the notification to. Leave it as null to send only to individual users. |
IList<UserInfo> | users | The list of users to send the notification to. Leave it as null to send only to roles. |
SetNotificationTypeActions(IList<NotificationTypeAction>, Int32)
Set the actions for a NotificationType.
Declaration
public void SetNotificationTypeActions(IList<NotificationTypeAction> actions, int notificationTypeId)
Parameters
Type | Name | Description |
---|---|---|
IList<NotificationTypeAction> | actions | The actions. |
System.Int32 | notificationTypeId | Id of the notification type. |