internal static string GetActionAsForm(this HtmlHelper html, ActionContext actionContext, string controllerName, object routeValues, out string value, out RouteValueDictionary attributes) {
            const string tagType = "form";

            IEnumerable<ElementDescriptor> concurrencyElements = html.GetConcurrencyElements(actionContext.Target, actionContext.GetConcurrencyActionInputId);

            string elements = concurrencyElements.Aggregate(String.Empty, (s, t) => s + t.BuildElement());

            RouteValueDictionary routeValueDictionary;
            if (actionContext.ParameterValues != null && actionContext.ParameterValues.Any()) {
                // custom values have been set so push the values into view data 
                // fields will be hidden and action will be 'none' so that action goes straight through and doesn't prompt for 
                // parameters 

                foreach (var pc in actionContext.GetParameterContexts(html.Facade())) {
                    if (pc.CustomValue != null) {
                        html.ViewData[html.IdHelper().GetParameterInputId((actionContext.Action), (pc.Parameter))] = pc.CustomValue.Specification.IsParseable ? pc.CustomValue.GetDomainObject() : pc.CustomValue;
                    }
                }

                List<ElementDescriptor> paramElements = html.ActionParameterFields(actionContext).ToList();
                elements = paramElements.Aggregate(String.Empty, (s, t) => s + t.BuildElement());
                routeValueDictionary = new RouteValueDictionary();
            } else {
                routeValueDictionary = new RouteValueDictionary(new { action = "action" });
            }

            value = (elements + GetSubmitButton(null, actionContext.Action.Name, IdConstants.ActionInvokeAction, routeValueDictionary)).WrapInDivTag();

            attributes = new RouteValueDictionary(new {
                action = html.GenerateUrl(Action(actionContext.Action.Id), controllerName, new RouteValueDictionary(routeValues)),
                method = "post",
                id = actionContext.GetActionId(),
                @class = actionContext.GetActionClass()
            });
            return tagType;
        }
 internal static string GetVetoedAction(this HtmlHelper html, ActionContext actionContext, IConsentFacade consent, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class = actionContext.GetActionClass(),
         title = consent.Reason
     });
     return "div";
 }
 internal static string GetDuplicateAction(this HtmlHelper html, ActionContext actionContext, string reason, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class = actionContext.GetActionClass(),
         title = reason
     });
     return "div";
 }
Пример #4
0
 private static string GetVetoedAction(ActionContext actionContext, IConsent consent, out string value, out RouteValueDictionary attributes) {
     value = actionContext.Action.Name;
     attributes = new RouteValueDictionary(new {
         id = actionContext.GetActionId(),
         @class =  actionContext.GetActionClass(), 
         title = consent.Reason
     });
     return "div";
 }