public AppointModeratorFormBuilder(
     ISelectListBuilder selectListBuilder,
     EndowmentRepositories repositories)
 {
     _selectListBuilder = selectListBuilder;
     _repositories = repositories;
 }
 public AppointManagerFormBuilder(
     ISelectListBuilder selectListBuilder, 
     EndowmentRepositories endowmentRepositories)
 {
     _selectListBuilder = selectListBuilder;
     _endowmentRepositories = endowmentRepositories;
 }
Exemplo n.º 3
0
        public static IEnumerable<SelectListItem> GetSelectListItems(HtmlHelper html, ISelectListBuilder dropDownList, string expressionText)
        {
            string fullHtmlFieldName = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expressionText);

            bool flag = false;

            IEnumerable<SelectListItem> selectList = dropDownList.SelectList();
            bool allowMultiple = dropDownList.Attr("multiple") == "multiple";

            if (selectList == null)
            {
                selectList = html.GetSelectListItemsFromViewData(expressionText);
                flag = true;
            }
            object defaultValue = allowMultiple ? html.GetModelStateValue(fullHtmlFieldName, typeof(string[])) : html.GetModelStateValue(fullHtmlFieldName, typeof(string));
            if (!flag && defaultValue == null && !String.IsNullOrEmpty(expressionText))
            {
                defaultValue = html.ViewData.Eval(expressionText);
            }
            if (defaultValue != null)
            {
                selectList = GetSelectListWithDefaultValue(selectList, defaultValue, allowMultiple);
            }
            return selectList;
        }
 public ContactViewModelBuilder(
     EndowmentRepositories endowmentRepositories, 
     ISelectListBuilder selectListBuilder)
 {
     _endowmentRepositories = endowmentRepositories;
     _selectListBuilder = selectListBuilder;
 }
Exemplo n.º 5
0
 public UsersViewModelBuilder(
     ISelectListBuilder selectListBuilder, 
     EndowmentRepositories endowmentRepositories)
 {
     _selectListBuilder = selectListBuilder;
     _endowmentRepositories = endowmentRepositories;
 }
        private SelectListSourceAttribute(string dataSourcePropertyName, ISelectListBuilder selectListBuilder, string optionalLabel, string templateName)
            : base(templateName)
        {
            if (selectListBuilder == null)
            {
                throw new ArgumentNullException("selectListBuilder");
            }

            _dataSourcePropertyName = dataSourcePropertyName;
            _selectListBuilder      = selectListBuilder;
            _optionalLabel          = optionalLabel;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression.
        /// </summary>
        public static ISelectListBuilder BuildDropDownListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper,
                                                                                  Expression <Func <TModel, TProperty> > expression,
                                                                                  Action <ISelectListBuilder> builderExpression)
        {
            ISelectListBuilder builder = htmlHelper.BuildDropDownListFor(expression);

            if (builderExpression != null)
            {
                builderExpression.Invoke(builder);
            }
            return(builder);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper and the name of the form field.
        /// </summary>
        /// <param name="htmlHelper">The HTML helper instance that this method extends.</param>
        /// <param name="name">The name of the form field to return.</param>
        /// <param name="builderExpression">The builder expression.</param>
        /// <returns>
        /// An HTML select element.
        /// </returns>
        public static ISelectListBuilder BuildDropDownList(this HtmlHelper htmlHelper,
                                                           string name,
                                                           Action <ISelectListBuilder> builderExpression)
        {
            ISelectListBuilder builder = htmlHelper.BuildDropDownList(name);

            if (builderExpression != null)
            {
                builderExpression.Invoke(builder);
            }
            return(builder);
        }
Exemplo n.º 9
0
        public static IHtmlString Render(HtmlHelper html, ISelectListBuilder selectListBuilder, FormGroupDisplay display, string expressionText, Func<MvcHtmlString> hiddenField)
        {
            bool readOnlyMode = display == FormGroupDisplay.ReadOnly, labelWithHiddenFieldMode = display == FormGroupDisplay.LabelWithHiddenField;

            if (readOnlyMode || labelWithHiddenFieldMode)
            {
                var builder = new HtmlTagBuilder("div");

                builder.Attr(selectListBuilder.HtmlAttributes);

                IEnumerable<SelectListItem> selectList = SelectListHelper.GetSelectListItems(html, selectListBuilder, expressionText);

                builder.InternalBuilder.InnerHtml = GetDisplayText(selectList);

                if (labelWithHiddenFieldMode)
                {
                    builder.InternalBuilder.InnerHtml += hiddenField();
                }

                return MvcHtmlString.Create(builder.ToHtmlString());
            }

            return selectListBuilder.AddClass("form-control");
        }
Exemplo n.º 10
0
        public static IHtmlString Render(HtmlHelper html, ISelectListBuilder selectListBuilder, FormGroupDisplay display, string expressionText, Func <MvcHtmlString> hiddenField)
        {
            bool readOnlyMode = display == FormGroupDisplay.ReadOnly, labelWithHiddenFieldMode = display == FormGroupDisplay.LabelWithHiddenField;

            if (readOnlyMode || labelWithHiddenFieldMode)
            {
                var builder = new HtmlTagBuilder("div");

                builder.Attr(selectListBuilder.HtmlAttributes);

                IEnumerable <SelectListItem> selectList = SelectListHelper.GetSelectListItems(html, selectListBuilder, expressionText);

                builder.InternalBuilder.InnerHtml = GetDisplayText(selectList);

                if (labelWithHiddenFieldMode)
                {
                    builder.InternalBuilder.InnerHtml += hiddenField();
                }

                return(MvcHtmlString.Create(builder.ToHtmlString()));
            }

            return(selectListBuilder.AddClass("form-control"));
        }
Exemplo n.º 11
0
        public override IHtmlString RenderControl(FormGroupDisplay display)
        {
            ISelectListBuilder selectListBuilder = Html.BuildDropDownListFor(InitExpression).BuildWith(SelectListModifier);

            return(SelectListGroupHelper.Render(Html, selectListBuilder, display, ExpressionHelper.GetExpressionText(InitExpression), () => Html.HiddenFor(InitExpression)));
        }
 public DisappointModeratorsFormBuilder(
     ISelectListBuilder selectListBuilder)
 {
     _selectListBuilder = selectListBuilder;
 }
 /// <summary>
 /// Gets the selectlist property.
 /// </summary>
 public static IEnumerable <SelectListItem> SelectList(this ISelectListBuilder instance)
 {
     return(instance.Prop <IEnumerable <SelectListItem> >("selectlist"));
 }
Exemplo n.º 14
0
        public static IEnumerable <SelectListItem> GetSelectListItems(HtmlHelper html, ISelectListBuilder dropDownList, string expressionText)
        {
            string fullHtmlFieldName = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expressionText);

            bool flag = false;

            IEnumerable <SelectListItem> selectList = dropDownList.SelectList();
            bool allowMultiple = dropDownList.Attr("multiple") == "multiple";

            if (selectList == null)
            {
                selectList = html.GetSelectListItemsFromViewData(expressionText);
                flag       = true;
            }
            object defaultValue = allowMultiple ? html.GetModelStateValue(fullHtmlFieldName, typeof(string[])) : html.GetModelStateValue(fullHtmlFieldName, typeof(string));

            if (!flag && defaultValue == null && !String.IsNullOrEmpty(expressionText))
            {
                defaultValue = html.ViewData.Eval(expressionText);
            }
            if (defaultValue != null)
            {
                selectList = GetSelectListWithDefaultValue(selectList, defaultValue, allowMultiple);
            }
            return(selectList);
        }
 public ModeratorReviewFormBuilder(
     ISelectListBuilder selectListBuilder)
 {
     _selectListBuilder = selectListBuilder;
 }
Exemplo n.º 16
0
 public ContactEditFormBuilder(EndowmentRepositories repositories,
     ISelectListBuilder selectListBuilder)
 {
     _repositories = repositories;
     _selectListBuilder = selectListBuilder;
 }