Skip to content

8. Notification Service

ParamVarunReddy edited this page Apr 2, 2024 · 1 revision

Notification Service

Purpose and Intent:

The NotificationService class within the RexStudios.LanguageDependentNotification namespace serves as a central component for retrieving notification texts and entities from Dynamics CRM. It encapsulates the logic for fetching notification details based on various criteria such as entity name, command text, and language code. By encapsulating interactions with notification repositories and user service, it promotes modularity and encapsulation, simplifying access to notification-related data for consuming applications.

Design Patterns:

  1. Dependency Injection: The class employs the Dependency Injection pattern to inject instances of repository interfaces (INotificationRepo, INotificationTypeRepo) and the UserService into its constructor. This pattern enables loose coupling and facilitates unit testing by allowing alternative implementations to be easily substituted.
  2. Abstract Factory: While not explicitly implemented, the class exhibits characteristics of the Abstract Factory pattern by providing methods to retrieve notification details based on different criteria, acting as a factory for creating notification-related entities.

Method Summaries:

  • GetNotificationTexts(string entityName, string commandText, int languageCode): Retrieves the notification text associated with the specified entity name, command text, and language code. It delegates the retrieval process to the underlying INotificationRepo implementation.
  • GetNotificationTextByName(string CommandText, string EntityLogicalName, string NotificationType): Retrieves notification entities based on the provided command text, entity logical name, and notification type. It invokes the corresponding method of the INotificationRepo implementation to fetch the entities.
  • GetNotificationTextsByEntityName(string entityName, int languagecode): Retrieves notification texts associated with the specified entity name and language code. If the language code is not provided, it retrieves the user's language code using the UserService and then fetches the notification texts. This method utilizes the INotificationRepo and UserService implementations for data retrieval.

Encapsulation of Repositories and UserService:

Similar to the UserService, the NotificationService class encapsulates interactions with notification repositories (INotificationRepo, INotificationTypeRepo) and the UserService. This encapsulation shields consuming applications from the complexities of repository and service instantiation, providing a simplified interface for accessing notification-related data. Developers can directly consume the NotificationService class without needing to manage repository or service instances separately. Additionally, the class can be easily extended or overridden to accommodate specific business requirements by subclassing or method overloading.

Methodologies and Usage:

Developers can utilize the NotificationService class to obtain notification texts and entities from Dynamics CRM by invoking its various methods, such as GetNotificationTexts, GetNotificationTextByName, and GetNotificationTextsByEntityName. These methods encapsulate the complexity of fetching notification details based on different criteria, providing a simplified interface for consuming applications. By leveraging the INotificationService interface, developers can maintain a clear separation of concerns and easily swap out implementations if required. This promotes code maintainability and extensibility, ensuring that the notification service remains adaptable to future changes in the application requirements.

Clone this wiki locally