-
Notifications
You must be signed in to change notification settings - Fork 0
8. Notification Service
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.
-
Dependency Injection: The class employs the Dependency Injection pattern to inject instances of repository interfaces (
INotificationRepo,INotificationTypeRepo) and theUserServiceinto its constructor. This pattern enables loose coupling and facilitates unit testing by allowing alternative implementations to be easily substituted. - 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.
-
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
INotificationRepoimplementation. -
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
INotificationRepoimplementation 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
UserServiceand then fetches the notification texts. This method utilizes theINotificationRepoandUserServiceimplementations for data retrieval.
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.
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.