예제 #1
0
 public static string PostUrl(this IUrlHelper helper, string url, string id)
 {
     if (url.IsNullOrWhiteSpace())
     {
         url = "/";
     }
     return(helper.Content($"{url}{(url.EndsWith("/") ? "" : "/")}{StringKeys.PathFormat(StringKeys.RouteValue_Post)}{id}.html"));
 }
예제 #2
0
 public static string PostUrl(this IUrlHelper helper, string url, string id)
 {
     if (url.IsNullOrWhiteSpace())
     {
         url = "/";
     }
     return(url + (url.EndsWith("/") ? "" : "/") + StringKeys.PathFormat(StringKeys.RouteValue_Post) + id);
 }
예제 #3
0
        public static string Page(this IUrlHelper helper, int pageIndex)
        {
            var category = helper.ActionContext.RouteData.GetCategory();

            if (category > 0)
            {
                return(helper.ActionContext.RouteData.GetPath() +
                       "/" + StringKeys.PathFormat(StringKeys.RouteValue_Category) + category +
                       "/" + StringKeys.PathFormat(StringKeys.RouteValue_Page) + pageIndex);
            }
            return(helper.ActionContext.RouteData.GetPath() + "/" + StringKeys.PathFormat(StringKeys.RouteValue_Page) + pageIndex);
        }
예제 #4
0
        public static string CategoryUrl(this IUrlHelper helper, string id)
        {
            string url             = helper.ActionContext.RouteData.GetPath();
            string currentCategory = helper.ActionContext.RouteData.GetCategory().ToString();

            if (currentCategory != id)
            {
                return($"{url}{(url.EndsWith("/") ? "" : "/")}{StringKeys.PathFormat(StringKeys.RouteValue_Category)}{id}");
            }
            else
            {
                return(url);
            }
        }
예제 #5
0
        public static string CategoryUrl(this IUrlHelper helper, string id)
        {
            string path            = helper.ActionContext.RouteData.GetPath();
            string currentCategory = helper.ActionContext.RouteData.GetCategory().ToString();

            if (currentCategory != id)
            {
                return($"{path.TrimEnd('/')}/{StringKeys.PathFormat(StringKeys.RouteValue_Category)}{id}");
            }
            else
            {
                return(path);
            }
        }
예제 #6
0
        public static string Page(this IUrlHelper helper, int pageIndex)
        {
            var category = helper.ActionContext.RouteData.GetCategory();

            if (category > 0)
            {
                if (pageIndex > 0)
                {
                    return($"{helper.ActionContext.RouteData.GetPath()}/{helper.ActionContext.RouteData.GetCategoryUrl() ?? (StringKeys.PathFormat(StringKeys.RouteValue_Category) + category)}/{StringKeys.PathFormat(StringKeys.RouteValue_Page)}{pageIndex}");
                }
                else
                {
                    return($"{helper.ActionContext.RouteData.GetPath()}/{helper.ActionContext.RouteData.GetCategoryUrl() ?? (StringKeys.PathFormat(StringKeys.RouteValue_Category) + category)}");
                }
            }
            if (pageIndex > 0)
            {
                return($"{helper.ActionContext.RouteData.GetPath()}/{StringKeys.PathFormat(StringKeys.RouteValue_Page)}{pageIndex}");
            }
            return($"{helper.ActionContext.RouteData.GetPath()}");
        }