Beispiel #1
0
        public static HtmlString InputWithLabelFor <T>(Expression <Func <T, DateTime?> > propertySelector,
                                                       string format = "M/D/YYYY", int?labelCols = null, int?inputCols = null, string label = null, DateTimePreservationOptions preserve = DateTimePreservationOptions.None, int stepping = 1)
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            return(DateTimeWithLabel(propertyModel.DisplayNameLabel(label), propertyModel.JsVariableForBinding, format, preserve, stepping, labelCols, inputCols));
        }
Beispiel #2
0
        public static HtmlString InputFor <T>(Expression <Func <T, DateTime?> > propertySelector,
                                              string format = null, DateTimePreservationOptions preserve = DateTimePreservationOptions.None, int?stepping = null)
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            return(DateTime(propertyModel.JsVariableForBinding, format, preserve, stepping));
        }
Beispiel #3
0
        public static HtmlString SelectFor <T>(Expression <Func <T, string> > propertySelector,
                                               string placeholder = "")
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            placeholder = placeholder ?? propertyModel.DisplayName;
            return(SelectString(propertyModel, placeholder));
        }
Beispiel #4
0
        public static HtmlString DisplayHtml <T>(Expression <Func <T, object> > propertySelector)
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            string result = string.Format(@"
                <div class=""form-control-static"" data-bind=""html: {0}()""></div>",
                                          propertyModel.JsVariableForBinding);

            return(new HtmlString(result));
        }
Beispiel #5
0
        public static HtmlString SelectForManyToMany <T>(Expression <Func <T, object> > propertySelector, string placeholder = "", string prefix = "", string areaName = "", int pageSize = 25)
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            if (propertyModel != null)
            {
                return(SelectForManyToMany(propertyModel, placeholder, prefix, areaName, pageSize));
            }
            return(HtmlString.Empty);
        }
Beispiel #6
0
        public static HtmlString SelectForObject <T>(Expression <Func <T, object> > propertySelector,
                                                     string placeholder = "", string prefix = "")
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            if (propertyModel != null)
            {
                return(SelectObject(propertyModel, placeholder, prefix, propertyModel.ObjectIdProperty == null ? !propertyModel.IsRequired : !propertyModel.ObjectIdProperty.IsRequired));
            }
            return(HtmlString.Empty);
        }
Beispiel #7
0
        public static HtmlString DisplayFor <T>(Expression <Func <T, DateTimeOffset> > propertySelector,
                                                string format = null, DateTimePreservationOptions preserve = DateTimePreservationOptions.None)
        {
            var        propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);
            HtmlString returnString;

            switch (preserve)
            {
            case (DateTimePreservationOptions.Date):
                returnString = DisplayDate(propertyModel.JsVariableForBinding, format);
                break;

            case (DateTimePreservationOptions.Time):
                returnString = DisplayTime(propertyModel.JsVariableForBinding, format);
                break;

            default:
                returnString = DisplayDateTime(propertyModel.JsVariableForBinding, format);
                break;
            }

            return(returnString);
        }
Beispiel #8
0
        public static HtmlString DisplayFor <T>(Expression <Func <T, object> > propertySelector, bool linkObject = false)
        {
            var        propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);
            HtmlString returnString;

            if (propertyModel.IsDateOnly)
            {
                returnString = DisplayDate(propertyModel.JsVariableForBinding);
            }
            else if (propertyModel.Type.IsDate)
            {
                returnString = DisplayDateTime(propertyModel.JsVariableForBinding);
            }
            else if (propertyModel.IsManytoManyCollection)
            {
                returnString = DisplayManyToMany(propertyModel);
            }
            else if (propertyModel.Type.IsBool)
            {
                returnString = DisplayCheckbox(propertyModel.JsVariableForBinding);
            }
            else if (propertyModel.IsPOCO && !propertyModel.IsComplexType)
            {
                returnString = DisplayObject(propertyModel, linkObject);
            }
            else if (propertyModel.Type.IsEnum || (propertyModel.PureType.IsEnum && propertyModel.Type.IsNullable))
            {
                returnString = DisplayEnum(propertyModel);
            }
            else
            {
                returnString = DisplayText(propertyModel.JsVariableForBinding);
            }

            return(returnString);
        }
Beispiel #9
0
        public static HtmlString BooleanValueFor <T>(Expression <Func <T, bool?> > propertySelector, string trueText = "Yes", string falseText = "No")
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            return(BooleanSelect(propertyModel.JsVariableForBinding, trueText, falseText));
        }
Beispiel #10
0
        public static HtmlString InputFor <T>(Expression <Func <T, bool?> > propertySelector, string bindingName = "checked")
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            return(Checkbox(propertyModel.JsVariableForBinding, bindingName));
        }
Beispiel #11
0
        public static HtmlString Property <T, TProp>(Expression <Func <T, TProp> > propertySelector, bool editable)
        {
            var propertyModel = ReflectionRepository.PropertyBySelector(propertySelector);

            return(Property(propertySelector, editable));
        }