Exemplo n.º 1
0
 public FormFieldValueViewModel(Constants.FieldType type, string value)
 {
     this.Value = value;
     this.FieldType = type;
 }
Exemplo n.º 2
0
        public static FormFieldViewModel CreateFromObject(FormField field, Constants.FormFieldMode mode)
        {
            if (field != null)
            {

                return new FormFieldViewModel
                {
                    DomId = field.DomId.Value,
                    Id = field.ID,
                    Label = field.Label.IsNullOrEmpty() ? "Click to edit" : field.Label,
                    Text = field.Text,
                    FieldType = (Constants.FieldType)Enum.Parse(typeof(Constants.FieldType), field.FieldType),
                    IsRequired = field.IsRequired.Value,
                    MaxCharacters = field.MaxChars.Value,
                    HoverText = field.HoverText,
                    Hint = field.Hint,
                    SubLabel = field.SubLabel,
                    Size = field.Size,
                    Columns = field.Columns.Value,
                    Rows = field.Rows.Value,
                    Options = field.Options,
                    SelectedOption = field.SelectedOption,
                    HelpText = field.HelpText,
                    Validation = field.Validation,
                    Order = field.Order.Value,
                    MinimumAge = field.MinimumAge,
                    MaximumAge = field.MaximumAge,
                    Mode = mode,
                    MaxFileSize = field.MaxFilesizeInKb ?? field.MaxFilesizeInKb.Value,
                    MinFileSize = field.MinFilesizeInKb ?? field.MinFilesizeInKb.Value,
                    ValidFileExtensions=field.ValidFileExtensions,
                    DateAdded = field.DateAdded
                };
            }

            return FormFieldViewModel.Initialize();
        }
Exemplo n.º 3
0
        public static FormViewModel CreateFromObject(Form form, Constants.FormFieldMode mode)
        {
            if (form != null)
            {

                var formView = CreateBasicFromObject(form);

                if (form.FormFields.Count() > 0)
                {
                    form.FormFields.OrderBy(o => o.Order).Each((field, index) =>
                    {

                        formView.Fields.Add(FormFieldViewModel.CreateFromObject(field, mode));
                    });
                }

                return formView;
            }
            return FormViewModel.Initialize();
        }