if (!(context.ActionDescriptor is ControllerActionDescriptor actionDescriptor)) return;
if (actionDescriptor.ControllerTypeInfo != typeof(ProductController) || actionDescriptor.ActionName != "ProductDetails" || context.HttpContext.Request.Method != "GET") { return; } var result = context.Result as ViewResult; if (result == null) return; var model = result.Model as ProductDetailsModel; if (model == null) return;
var product = _productService.GetProductById(model.Id);
var attributesXml = ...................................;
model = _productModelFactory.PrepareProductDetailsModel(product, new ShoppingCartItem { AttributesXml = attributesXml, }, false); }
Because your local model variable is a reference to the result.Model. I.e. model.Name affects the referenced object, whereas when you reassign model, you are only affecting your local variable. Try result.Model = _productModelFactory.PrepareProductDetailsModel(...
(I don't recall if it's readonly. If it is, then you will need to replace each of the properties just like you did with Name)