Example #1
0
        public static IHtmlContent RPCSDropDownList <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, string name,
                                                                               IEnumerable <SelectListItem> selectList, OperationSet editRights, OperationSet displayRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" });

            if (appUserSvc.HasAccess(editRights))
            {
                var contents = HtmlHelperSelectExtensions.DropDownList(html, name, selectList, new { @class = "form-control" });

                string result = String.Concat("<div class=\"form-group\">",
                                              GetString(label),
                                              "<div class=\"col-md-8\">",
                                              GetString(contents),
                                              "</div>",
                                              "</div>");
                return(new HtmlString(result));
            }
            if (appUserSvc.HasAccess(displayRights))
            {
                IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression);
                string       result   = String.Concat("<div class=\"form-group\">",
                                                      GetString(label),
                                                      "<div class=\"col-md-8\">",
                                                      GetString(contents),
                                                      "</div>",
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)),
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)),
                                                      "</div>");
                return(new HtmlString(result));
            }
            string v = GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression));
            string l = GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression));

            return(new HtmlString(v + l));
        }