public static ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> SetAction <TModel, TForm>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> builder, ActionResult result)
            where TForm : Form
        {
            IT4MVCActionResult callInfo = result.GetT4MVCResult();

            builder.SetAction(UrlHelper.GenerateUrl(null, callInfo.Action, callInfo.Controller, callInfo.Protocol, null, null, result.GetRouteValueDictionary(),
                                                    builder.GetConfig().GetHtmlHelper().RouteCollection, builder.GetConfig().GetHtmlHelper().ViewContext.RequestContext, true));
            return(builder);
        }
 public static ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> SetLinkAction <TTag, TModel>(
     this ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> builder, ActionResult result)
     where TTag : Tag, IHasLinkExtensions
 {
     if (result != null)
     {
         IT4MVCActionResult callInfo = result.GetT4MVCResult();
         builder.SetHref(UrlHelper.GenerateUrl(null, callInfo.Action, callInfo.Controller, callInfo.Protocol, null, null, result.GetRouteValueDictionary(),
                                               builder.GetConfig().GetHtmlHelper().RouteCollection, builder.GetConfig().GetHtmlHelper().ViewContext.RequestContext, true));
     }
     return(builder);
 }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, Form> SetAction <TModel>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, Form> builder, string actionName, string controllerName, object routeValues = null)
        {
            RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : routeValues as RouteValueDictionary;

            if (routeValueDictionary == null)
            {
                new RouteValueDictionary(routeValues);
            }
            builder.SetAction(UrlHelper.GenerateUrl(null, actionName, controllerName, routeValueDictionary,
                                                    builder.GetConfig().HtmlHelper.RouteCollection, builder.GetConfig().HtmlHelper.ViewContext.RequestContext, true));
            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> SetRoute <TModel, TForm>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, TForm> builder, string routeName, object routeValues = null)
            where TForm : Form
        {
            RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : routeValues as RouteValueDictionary;

            if (routeValueDictionary == null)
            {
                routeValueDictionary = new RouteValueDictionary(routeValues);
            }
            builder.SetAction(UrlHelper.GenerateUrl(routeName, null, null, routeValueDictionary,
                                                    builder.GetConfig().HtmlHelper.RouteCollection, builder.GetConfig().HtmlHelper.ViewContext.RequestContext, false));
            return(builder);
        }
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> SetRoute <TTag, TModel>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> builder, string routeName, object routeValues = null)
            where TTag : Tag, IHasLinkExtensions
        {
            RouteValueDictionary routeValueDictionary = routeValues == null ? new RouteValueDictionary() : routeValues as RouteValueDictionary;

            if (routeValueDictionary == null)
            {
                new RouteValueDictionary(routeValues);
            }
            builder.SetHref(UrlHelper.GenerateUrl(routeName, null, null, routeValueDictionary,
                                                  builder.GetConfig().HtmlHelper.RouteCollection, builder.GetConfig().HtmlHelper.ViewContext.RequestContext, false));
            return(builder);
        }
Example #6
0
        public static ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> For <TTag, TModel, TValue>(
            this ComponentBuilder <MvcBootstrapConfig <TModel>, TTag> builder, Expression <Func <TModel, TValue> > expression, TValue value)
            where TTag : FormButton
        {
            var    config         = (MvcBootstrapConfig <TModel>)builder.GetConfig();
            var    html           = config.GetHtmlHelper();
            var    metadata       = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
            string expressionText = ExpressionHelper.GetExpressionText(expression);
            string name           = GetControlName(html, expressionText);
            string label          = GetControlLabel(metadata, expressionText);

            return(builder
                   .SetName(name)
                   .SetControlLabel(label)
                   .SetValue(value));
        }
        // Typography

        public static ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> ListFor <TComponent, TModel, TValue>(
            this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper,
            Expression <Func <TModel, IEnumerable <TValue> > > expression, Func <TValue, object> item, ListType listType = ListType.Unstyled)
            where TComponent : Component, ICanCreate <Typography.List>
        {
            ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> builder =
                new ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List>(helper.GetConfig(), helper.List(listType).GetComponent());
            IEnumerable <TValue> values = ModelMetadata.FromLambdaExpression(expression, builder.GetConfig().HtmlHelper.ViewData).Model as IEnumerable <TValue>;

            if (values != null)
            {
                foreach (TValue value in values)
                {
                    builder.AddChild(x => x.ListItem(item(value)));
                }
            }
            return(builder);
        }