public FormFieldValueViewModel(Constants.FieldType type, string value) { this.Value = value; this.FieldType = type; }
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(); }
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(); }