using Microsoft.AspNetCore.Http; using Nop.Core.Domain.Catalog; using Nop.Core.Events; using Nop.Services.Events; namespace Nop.Plugin.Misc.AuctionPlugin.Services; /// /// Represents plugin event consumer /// public class EventConsumer : IConsumer> //IConsumer, //IConsumer>, //IConsumer>, //IConsumer>, //IConsumer, //IConsumer, //IConsumer { #region Fields //protected readonly FacebookPixelService _facebookPixelService; protected readonly IHttpContextAccessor _httpContextAccessor; #endregion #region Ctor //public EventConsumer(FacebookPixelService facebookPixelService, public EventConsumer(IHttpContextAccessor httpContextAccessor) { //_facebookPixelService = facebookPixelService; _httpContextAccessor = httpContextAccessor; } #endregion #region Methods /// /// Handle shopping cart item inserted event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(EntityInsertedEvent eventMessage) //{ // if (eventMessage?.Entity != null) // { // //notify clients through SignalR // } //} /// /// Handle order placed event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(OrderPlacedEvent eventMessage) //{ // if (eventMessage?.Order != null) // { // // // } //} /// /// Handle product details model prepared event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(ModelPreparedEvent eventMessage) //{ // if (eventMessage?.Model is ProductDetailsModel productDetailsModel) // { // // // } //} /// /// Handle page rendering event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(PageRenderingEvent eventMessage) //{ // var routeName = eventMessage.GetRouteName() ?? string.Empty; // if (routeName == FacebookPixelDefaults.CheckoutRouteName || routeName == FacebookPixelDefaults.CheckoutOnePageRouteName) // await _facebookPixelService.SendInitiateCheckoutEventAsync(); // if (_httpContextAccessor.HttpContext.GetRouteValue("area") is not string area || area != AreaNames.ADMIN) // await _facebookPixelService.SendPageViewEventAsync(); //} /// /// Handle product search event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(ProductSearchEvent eventMessage) //{ // if (eventMessage?.SearchTerm != null) // await _facebookPixelService.SendSearchEventAsync(eventMessage.SearchTerm); //} /// /// Handle message token added event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(MessageTokensAddedEvent eventMessage) //{ // if (eventMessage?.Message?.Name == MessageTemplateSystemNames.CONTACT_US_MESSAGE) // await _facebookPixelService.SendContactEventAsync(); //} /// /// Handle customer registered event /// /// Event message /// A task that represents the asynchronous operation //public async Task HandleEventAsync(CustomerRegisteredEvent eventMessage) //{ // if (eventMessage?.Customer != null) // await _facebookPixelService.SendCompleteRegistrationEventAsync(); //} public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { //send notification on SignalR } #endregion }