Just started to upgrade one of our sites to v4.0 and been through the process of upgrading the Action Filters. Thought someone else might interested in this, so I created (my first) a blog post:
=> using action filter we can add our extra logic before action executing or after action executed => can check a controller or action from default nop or from plugin
string controllerName = filterContext?.Controller.ToString(); if (string.IsNullOrEmpty(controllerName)) return;
var actionDescriptor = filterContext.ActionDescriptor as ControllerActionDescriptor; string actionName = actionDescriptor?.ActionName; if (string.IsNullOrEmpty(actionName)) return;
if (((actionDescriptor.ActionName.Equals("PtxInfo", StringComparison.InvariantCultureIgnoreCase) || actionDescriptor.ActionName.Equals("Info", StringComparison.InvariantCultureIgnoreCase)) || (controllerName.Equals("Nop.Web.Areas.Admin.Controllers.CustomerController", StringComparison.InvariantCultureIgnoreCase) || controllerName.Equals("PTX.Nop.Plugin.Custom.Controllers.Admin.PTXCustomerController", StringComparison.InvariantCultureIgnoreCase) && actionDescriptor.ActionName.Equals("Edit", StringComparison.InvariantCultureIgnoreCase))) && filterContext.HttpContext.Request.Method == "POST") { var customerEmail = filterContext.HttpContext.Request.Form["Email"]; if (string.IsNullOrEmpty(customerEmail)) return;
var customer = _customerService.GetCustomerByEmail(customerEmail); if (customer == null) return;
var contactRequest = _activeCampaignHttpClient.PrepareActiveCampaignContactRequest(customer); _activeCampaignHttpClient.ActiveCampaignUpdateContact(contactRequest, customer); } }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.