Esempio n. 1
0
 public static MvcHtmlString AllValidationMessages(this MyFfHtmlHelper helper, string modelName)
 {
     if (HasErrors(helper, modelName))
     {
         var message = string.Join(", ", helper.ViewData.ModelState[modelName].Errors.Select(e => e.ErrorMessage));
         return(new MvcHtmlString(message));
     }
     return(new MvcHtmlString(""));
 }
Esempio n. 2
0
        public static MvcHtmlString Render(this IEnumerable <PropertyVm> properties, MyFfHtmlHelper html)
        {
            var sb = new StringBuilder();

            foreach (var propertyVm in properties)
            {
                sb.AppendLine(propertyVm.Render(html).ToString());
            }
            return(new MvcHtmlString(sb.ToString()));
        }
Esempio n. 3
0
        public static string Render(this IEnumerable <PropertyVm> properties)
        {
            var helper = new MyFfHtmlHelper();
            var sb     = new StringBuilder();

            foreach (var propertyVm in properties)
            {
                sb.AppendLine(propertyVm.Render(helper).ToString()).ToString();
            }

            return(sb.ToString());
        }
Esempio n. 4
0
        public static ObjectChoices[] Choices(this MyFfHtmlHelper html, PropertyVm model)
        {
            var choices = (from obj in model.Choices.Cast <object>().ToArray()
                           let choiceType = obj == null ? model.Type : obj.GetType()
                                            let properties = FF.PropertiesFor(obj, choiceType)
                                                             .Each(p => p.Name = model.Name + "." + p.Name)
                                                             .Each(p => p.Readonly |= model.Readonly)
                                                             .Each(p => p.Id = Guid.NewGuid().ToString())
                                                             select new ObjectChoices
            {
                obj = obj, choiceType = choiceType, properties = properties,
                name = (obj != null ? obj.DisplayName() : choiceType.DisplayName())
            }).ToArray();

            return(choices);
        }
Esempio n. 5
0
 public static PropertyVm CreatePropertyVm(this MyFfHtmlHelper helper, Type objectType, string name)
 {
     return(helper.CreatePropertyVm(objectType, name));
 }
Esempio n. 6
0
 public static MvcHtmlString Render(this FormVm formVm, MyFfHtmlHelper html)
 {
     return(html.Partial("FormFactory/Form", formVm));
 }
Esempio n. 7
0
 public static MvcHtmlString Render(this PropertyVm propertyVm, MyFfHtmlHelper html)
 {
     return(html.Partial("FormFactory/Form.Property", propertyVm));
 }
Esempio n. 8
0
        public static MvcHtmlString BestProperty(this MyFfHtmlHelper html, PropertyVm vm)
        {
            string viewName = ViewFinderExtensions.BestPropertyName(html, vm);

            return(html.Partial(viewName, vm));
        }
Esempio n. 9
0
        public static MvcHtmlString BestPartial(this MyFfHtmlHelper html, object model, Type type = null, string prefix = null)
        {
            var partialViewName = BestViewName(html, type ?? model.GetType(), prefix);

            return(html.Partial(partialViewName, model));
        }
Esempio n. 10
0
 public static string BestViewName(this MyFfHtmlHelper html, Type type, string prefix = null)
 {
     return(FormFactory.ViewFinderExtensions.BestViewName(html, type, prefix));
 }
Esempio n. 11
0
        public static MvcHtmlString UnobtrusiveValidation(this MyFfHtmlHelper helper, PropertyVm property)
        {
            var unobtrusiveValidation = ValidationHelper.UnobtrusiveValidation(helper, property);

            return(new MvcHtmlString(unobtrusiveValidation));
        }
Esempio n. 12
0
 public static bool HasErrors(this MyFfHtmlHelper helper, string modelName)
 {
     return(helper.ViewData.ModelState.ContainsKey(modelName) &&
            helper.ViewData.ModelState[modelName].Errors.Count() > 0);
 }