Hi guys i have been trying to create a filter when the user add a item to cart and the quantity is greater than the stock, i want to return a custom view so the user can choice what they want to do next, but i am unable to show the view, this is my code (everything is ok the filter is working but i am unable to return the view):
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var _productService = EngineContext.Current.Resolve<IProductService>();
FormCollection form = (FormCollection)filterContext.ActionParameters["form"];
int productId = (int)filterContext.ActionParameters["productId"];
var product = _productService.GetProductById(productId);
int quantity = 1;
foreach (string formKey in form.AllKeys)
if (formKey.Equals(string.Format("addtocart_{0}.EnteredQuantity", productId), StringComparison.InvariantCultureIgnoreCase))
{
int.TryParse(form[formKey], out quantity);
break;
}
if (product.StockQuantity < quantity)
{
var subscribeUrl = new UrlHelper(filterContext.RequestContext).RouteUrl("Plugin.Triquimas.CheckOut.OutOfStock");
filterContext.Result = new RedirectResult(subscribeUrl);
}
What im doing wrong, In advance thanks for your help.