Class AppNotificationStore
SQL Server app notification store implementation. Manages persistence and retrieval of application notifications from the database.
Implements
Inherited Members
Namespace: DataWeb.Notification.SqlServer
Assembly: DataWeb.Data.SqlServer.dll
Syntax
public class AppNotificationStore : IAppNotificationStore
Constructors
AppNotificationStore(ISqlHelper)
SQL Server app notification store implementation. Manages persistence and retrieval of application notifications from the database.
Declaration
public AppNotificationStore(ISqlHelper sqlHelper)
Parameters
| Type | Name | Description |
|---|---|---|
| ISqlHelper | sqlHelper |
Properties
Name
Gets the name of the data store.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetNotificationAsync(AppNotificationFilter, CancellationToken)
Retrieves a single app notification based on the specified filter criteria.
Declaration
public Task<AppNotification> GetNotificationAsync(AppNotificationFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AppNotificationFilter | filter | Search criteria. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<AppNotification> | The notification found, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetNotificationCountAsync(AppNotificationFilter, CancellationToken)
Retrieves the total count of app notifications based on the specified filters.
Declaration
public Task<long> GetNotificationCountAsync(AppNotificationFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AppNotificationFilter | filter | Search criteria. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<long> | Number of notifications matching the filter criteria. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetNotificationsAsync(AppNotificationFilter, CancellationToken)
Retrieves a collection of app notifications based on the specified filters.
Declaration
public Task<IEnumerable<AppNotification>> GetNotificationsAsync(AppNotificationFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AppNotificationFilter | filter | Search criteria. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<AppNotification>> | Collection of notifications matching the filter criteria. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
RemoveAsync(string, CancellationToken)
Permanently deletes a notification from the database.
Declaration
public Task RemoveAsync(string notificationId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | notificationId | Identifier of the notification to delete. Cannot be null or empty. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If notificationId is null or empty. |
RemoveToDateAsync(DateTimeOffset, string, bool, CancellationToken)
Permanently deletes notifications up to a specified date, optionally including unread ones.
Declaration
public Task RemoveToDateAsync(DateTimeOffset endDate, string context, bool includeNotRead = false, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTimeOffset | endDate | Cutoff date: notifications on or before this date are deleted. |
| string | context | Notification context to filter by. |
| bool | includeNotRead | If true, also deletes unread notifications. Defaults to false. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
SetAsync(AppNotification, CancellationToken)
Inserts a new app notification into the database.
Declaration
public Task SetAsync(AppNotification notification, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AppNotification | notification | Notification to insert. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If notification is null. |
SetIsReadAsync(string, bool, CancellationToken)
Updates the read status of a specific notification.
Declaration
public Task SetIsReadAsync(string notificationId, bool isRead = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | notificationId | Identifier of the notification. Cannot be null or empty. |
| bool | isRead | Read status to set. Defaults to true. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If notificationId is null or empty. |
SetUserIsReadAllAsync(string, string, bool, CancellationToken)
Marks all readable notifications as read for a specific user and context.
Declaration
public Task SetUserIsReadAllAsync(string userIdMaster, string context, bool isRead = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userIdMaster | Identifier of the user. Cannot be null or empty. |
| string | context | Notification context to filter by. |
| bool | isRead | Read status to set. Defaults to true. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If userIdMaster is null or empty. |