using Nop.Core; using Nop.Core.Domain.Messages; using Nop.Core.Events; namespace Nop.Services.Messages; /// /// Event publisher extensions /// public static class EventPublisherExtensions { /// /// Publishes the newsletter subscribe event. /// /// The event publisher. /// The newsletter subscription. /// A task that represents the asynchronous operation public static async Task PublishNewsletterSubscribeAsync(this IEventPublisher eventPublisher, NewsLetterSubscription subscription) { await eventPublisher.PublishAsync(new EmailSubscribedEvent(subscription)); } /// /// Publishes the newsletter unsubscribe event. /// /// The event publisher. /// The newsletter subscription. /// A task that represents the asynchronous operation public static async Task PublishNewsletterUnsubscribeAsync(this IEventPublisher eventPublisher, NewsLetterSubscription subscription) { await eventPublisher.PublishAsync(new EmailUnsubscribedEvent(subscription)); } /// /// Entity tokens added /// /// Type /// Type /// Event publisher /// Entity /// Tokens /// A task that represents the asynchronous operation public static async Task EntityTokensAddedAsync(this IEventPublisher eventPublisher, T entity, System.Collections.Generic.IList tokens) where T : BaseEntity { await eventPublisher.PublishAsync(new EntityTokensAddedEvent(entity, tokens)); } /// /// Message token added /// /// Type /// Event publisher /// Message /// Tokens /// A task that represents the asynchronous operation public static async Task MessageTokensAddedAsync(this IEventPublisher eventPublisher, MessageTemplate message, System.Collections.Generic.IList tokens) { await eventPublisher.PublishAsync(new MessageTokensAddedEvent(message, tokens)); } }