Interface IAppNotificationService
Provides services to manage application notifications, such as retrieving and setting notification read status, saving notifications, and removing notifications.
Namespace: DataWeb.Notification
Assembly: DataWeb.Core.dll
Syntax
public interface IAppNotificationService
Methods
GetNotificationAsync(string, CancellationToken)
Retrieves a notification with the specified notificationId.
Declaration
Task<AppNotification> GetNotificationAsync(string messageId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | messageId | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<AppNotification> | An AppNotification object. |
GetNotificationsAsync(AppNotificationFilter, CancellationToken)
Retrieves a collection of notifications based on the provided filter.
Declaration
Task<IEnumerable<AppNotification>> GetNotificationsAsync(AppNotificationFilter filter, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppNotificationFilter | filter | The criteria used to filter notifications. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<AppNotification>> | A collection of notifications that match the provided filter. |
GetUserNotificationCountAsync(string, string, CancellationToken)
Retrieves the count of notifications for a user with the specified userIdMaster and context.
Declaration
Task<long> GetUserNotificationCountAsync(string userIdMaster, string context, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user identifier. |
string | context | The context of the notifications to retrieve. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<long> | The count of notifications as a long. |
GetUserNotificationViewForcedCountAsync(string, string, CancellationToken)
Retrieves the count of notifications with forced view for a user with the specified userIdMaster and context.
Declaration
Task<long> GetUserNotificationViewForcedCountAsync(string userIdMaster, string context, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user identifier. |
string | context | The context of the notifications to retrieve. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<long> | The count of notifications with forced view as a long. |
GetUserNotificationsAsync(string, string, CancellationToken)
Retrieves all notifications for a user with the specified userIdMaster and context.
Declaration
Task<IEnumerable<AppNotification>> GetUserNotificationsAsync(string userIdMaster, string context, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user identifier. |
string | context | The context of the notifications to retrieve. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<AppNotification>> | A collection of AppNotification objects. |
RemoveNotificationAsync(string, CancellationToken)
Removes a notification with the specified messageId.
Declaration
Task RemoveNotificationAsync(string notificationId, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | notificationId | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous remove operation. |
RemoveNotificationsToDateAsync(DateTime, string, bool, CancellationToken)
Removes all notifications with a notification date before or equal to the specified toDate and context.
Declaration
Task RemoveNotificationsToDateAsync(DateTime toDate, string context, bool includeNotRead = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DateTime | toDate | The maximum date for the notifications to remove. |
string | context | The context of the notifications to remove. |
bool | includeNotRead | Whether to include notifications that have not been read. Defaults to false. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous remove operation. |
SaveNotificationAsync(AppNotification, CancellationToken)
Saves an AppNotification object to the data store.
Declaration
Task SaveNotificationAsync(AppNotification notification, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppNotification | notification | The AppNotification object to save. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous save operation. |
SetNotificationIsReadAsync(string, bool, CancellationToken)
Sets the read status of a notification with the specified notificationId.
Declaration
Task SetNotificationIsReadAsync(string notificationId, bool isRead = true, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | notificationId | The Id of the notification to update. |
bool | isRead | The new read status. Defaults to true. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous update operation. |
SetUserNotificationIsReadAllAsync(string, string, bool, CancellationToken)
Sets the read status of all notifications for a user with the specified userIdMaster and context.
Declaration
Task SetUserNotificationIsReadAllAsync(string userIdMaster, string context, bool isRead = true, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user identifier. |
string | context | The context of the notifications to update. |
bool | isRead | The new read status. Defaults to true. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous update operation. |