Class AppNotificationStore
Azure Cosmos DB app notification store implementation. Manages persistence and retrieval of application notifications from the database.
Implements
Inherited Members
Namespace: DataWeb.Notification.AzureCosmosDB
Assembly: DataWeb.Data.AzureCosmosDB.dll
Syntax
public class AppNotificationStore : IAppNotificationStore
Constructors
AppNotificationStore(ICosmosHelper, IConfigurationService, TimeProvider)
Azure Cosmos DB app notification store implementation. Manages persistence and retrieval of application notifications from the database.
Declaration
public AppNotificationStore(ICosmosHelper cosmosHelper, IConfigurationService configurationService, TimeProvider timeProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| ICosmosHelper | cosmosHelper | |
| IConfigurationService | configurationService | |
| TimeProvider | timeProvider |
Properties
Name
Gets the name of the store implementation.
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)
Removes a specific app notification by its ID.
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)
Removes notifications older than the specified date.
Declaration
public Task RemoveToDateAsync(DateTimeOffset endDate, string context, bool includeNotRead = false, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTimeOffset | endDate | Cutoff date for deletion. |
| string | context | Notification context to filter by. |
| bool | includeNotRead | Whether to include unread notifications. Defaults to false. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If context is null or empty. |
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. |