예제 #1
0
        public static TemplateViewModel CreateFromObject(Template template1, Constants.TemplateFieldMode mode)
        {
            if (template1 != null)
            {
                var templateView = CreateBasicFromObject(template1);

                if (template1.TemplateFields.Count() > 0)
                {
                    template1.TemplateFields.OrderBy(o => o.Order).Each((field, index) =>
                    {
                        templateView.Fields.Add(TemplateFieldViewModel.CreateFromObject(field, mode));
                    });
                }

                return(templateView);
            }
            return(TemplateViewModel.Initialize());
        }
예제 #2
0
        public static TemplateFieldViewModel CreateFromObject(TemplateField field, Constants.TemplateFieldMode mode)
        {
            if (field != null)
            {
                var templateFieldView = new TemplateFieldViewModel
                {
                    DomId                    = field.DomId.Value,
                    TemplateFieldID          = field.TemplateFieldID,
                    Label                    = field.Label.Equals("") ? "Click to edit" : field.Label,
                    Text                     = field.Text,
                    FieldType                = (Constants.TemplateFieldType)Enum.Parse(typeof(Constants.TemplateFieldType), 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,
                    AddOthersOption          = field.AddOthersOption.Value,
                    OthersOption             = field.OthersOption,
                    OthersPlaceHolder        = string.IsNullOrEmpty(field.OthersPlaceHolder) ? "Others" : field.OthersPlaceHolder,
                    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,
                    ImageBase64              = field.ImageBase64,
                    MatrixRow                = field.MatrixRow,
                    MatrixColumn             = field.MatrixColumn,
                    PreRegistrationFieldName = field.PreRegistrationFieldName,
                    RegistrationFieldName    = field.RegistrationFieldName,
                    SummaryFieldName         = field.SummaryFieldName,
                    SummaryType              = field.SummaryType,
                    ConditionCriteria        = field.ConditionCriteria,
                    ConditionOptions         = field.ConditionOptions,
                    ConditionTemplateFieldID = field.ConditionTemplateFieldID,
                    StandardReferenceID      = field.StandardReferenceID,

                    CreatedBy = field.CreatedBy,
                    UpdatedBy = field.UpdatedBy
                };

                if (field.CreatedDateTime.HasValue)
                {
                    templateFieldView.CreatedDateTime = field.CreatedDateTime.Value;
                }

                if (field.UpdatedDateTime.HasValue)
                {
                    templateFieldView.UpdatedDateTime = field.UpdatedDateTime.Value;
                }

                return(templateFieldView);
            }

            return(TemplateFieldViewModel.Initialize());
        }