//public static IActionResult AddRouteValues(this IActionResult result, NameValueCollection nameValueCollection) //{ // // Copy all the values from the NameValueCollection into the route dictionary // if (nameValueCollection.AllKeys.Any(m => m == null)) //if it has a null, the CopyTo extension will crash! // { // var filtered = new NameValueCollection(nameValueCollection); // filtered.Remove(null); // filtered.CopyTo(result.GetRouteValueDictionary(), 0); // } // else // { // nameValueCollection.CopyTo(result.GetRouteValueDictionary(), replaceEntries: true); // } // return result; //} public static IActionResult AddRouteValue(this IActionResult result, string name, object value) { RouteValueDictionary routeValues = result.GetRouteValueDictionary(); ModelUnbinderHelpers.AddRouteValues(routeValues, name, value); return(result); }
public string PrevPageUrl(IUrlHelper url, IActionResult route) { var idx = route.GetRouteValueDictionary(); idx["Page"] = Math.Max(1, Page - 1); return(url.Action(route)); }
public string NextPageUrl(IUrlHelper url, IActionResult route) { var idx = route.GetRouteValueDictionary(); idx["Page"] = Math.Min(TotalPages(), Page + 1); return(url.Action(route)); }
public static IActionResult AddRouteValues(this IActionResult result, RouteValueDictionary routeValues) { RouteValueDictionary currentRouteValues = result.GetRouteValueDictionary(); // Add all the extra values foreach (var pair in routeValues) { ModelUnbinderHelpers.AddRouteValues(currentRouteValues, pair.Key, pair.Value); } return(result); }
public string OrderbyUrl(IUrlHelper url, LambdaExpression expression, IActionResult route) { var propertyName = ExpressionHelper.GetExpressionText(expression); var idx = route.GetRouteValueDictionary(); if (OrderBy == propertyName) { idx["OrderByDescending"] = !OrderByDescending; } else { idx["OrderBy"] = propertyName; idx["OrderByDescending"] = false; } return(url.Action(route)); }
public static IHtmlContent AutoNamedRouteLink(this IHtmlHelper htmlHelper, string linkText, IActionResult result, IDictionary <string, object> htmlAttributes, string protocol = null, string hostName = null, string fragment = null) { string routeName = autoRouteNameFromActionResult(result); return(htmlHelper.RouteLink(linkText, routeName, protocol ?? result.GetR4MvcResult().Protocol, hostName, fragment, result.GetRouteValueDictionary(), htmlAttributes)); }
public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, IActionResult result, FormMethod formMethod = FormMethod.Post, IDictionary <string, object> htmlAttributes = null) { return(htmlHelper.BeginRouteForm(routeName, result.GetRouteValueDictionary(), formMethod, null, htmlAttributes)); }
public static IHtmlContent ActionLink(this IHtmlHelper htmlHelper, string linkText, IActionResult result, object htmlAttributes = null, string protocol = null, string hostName = null, string fragment = null) { return(htmlHelper.RouteLink(linkText, null, protocol ?? result.GetR4MvcResult().Protocol, hostName, fragment, result.GetRouteValueDictionary(), HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes))); }
public static string Action(this IUrlHelper urlHelper, IActionResult result, string protocol = null, string hostName = null, string fragment = null) { return(urlHelper.RouteUrl(null, result.GetRouteValueDictionary(), protocol ?? result.GetR4MvcResult().Protocol, hostName, fragment)); }
public static string ActionAbsolute(this IUrlHelper urlHelper, IActionResult result) { var request = urlHelper.ActionContext.HttpContext.Request; return($"{request.Scheme}://{request.Host}{urlHelper.RouteUrl(result.GetRouteValueDictionary())}"); }