public static string ProductCategoryUrl(this IUrlHelper helper, Product.Models.ProductCategory productCategory) { if (productCategory.Url.IsNullOrWhiteSpace()) { return(helper.CategoryUrl(productCategory.ID)); } string url = helper.ActionContext.RouteData.GetPath(); string currentCategory = helper.ActionContext.RouteData.GetCategoryUrl(); if (currentCategory != productCategory.Url) { return($"{url}{(url.EndsWith("/") ? "" : "/")}{productCategory.Url}"); } else { return(url); } }
public static string ProductCategoryUrl(this IUrlHelper helper, Product.Models.ProductCategory productCategory) { if (productCategory.Url.IsNullOrWhiteSpace()) { return(helper.CategoryUrl(productCategory.ID)); } string path = helper.ActionContext.RouteData.GetPath(); string currentCategory = helper.ActionContext.RouteData.GetCategoryUrl(); if (currentCategory != productCategory.Url) { return($"{path.TrimEnd('/')}/{productCategory.Url}"); } else { return(path); } }