public FormViewModel Build(CachedForm cachedForm)
        {
            IEnumerable<CachedField> cachedFields = new CachedField[] { };

              if (!string.IsNullOrEmpty(cachedForm.CachedFields))
            cachedFields = JsonConvert.DeserializeObject<IEnumerable<CachedField>>(cachedForm.CachedFields);

              return new FormViewModel()
              {
            Id = cachedForm.FormId,
            Name = cachedForm.Name,
            Fields = cachedFields.Select(
              cf => new FieldViewModelBuilder(this.handler).Build(cf)
            )
              };
        }
        public FieldViewModel Build(CachedField cachedField)
        {
            IEnumerable<CachedFieldOption> cachedFieldOptions = new CachedFieldOption[] { };

              if (!string.IsNullOrEmpty(cachedField.CachedFieldOptions))
            cachedFieldOptions = JsonConvert.DeserializeObject<IEnumerable<CachedFieldOption>>(cachedField.CachedFieldOptions);

              return new FieldViewModel()
              {
            Id = cachedField.FieldId,
            FieldType = new FieldTypeViewModel() { Code = cachedField.FieldTypeCode },
            Name = cachedField.Name,
            FieldOptions = cachedFieldOptions.Select(
              fo => new FieldOptionViewModelBuilder(this.handler).Build(fo)
            )
              };
        }
示例#3
0
        private CachedField CacheField(Culture culture, Field field)
        {
            List<CachedFieldOption> cachedFieldOptions = new List<CachedFieldOption>();

              foreach (FieldOption fieldOption in this.handler.Storage.GetRepository<IFieldOptionRepository>().FilteredByFieldId(field.Id))
            cachedFieldOptions.Add(this.CacheFieldOption(culture, fieldOption));

              CachedField cachedField = new CachedField();

              cachedField.FieldId = field.Id;
              cachedField.FieldTypeCode = this.handler.Storage.GetRepository<IFieldTypeRepository>().WithKey(field.FieldTypeId).Code;
              cachedField.Name = this.GetLocalizationValue(culture.Id, field.NameId);
              cachedField.Position = field.Position;

              if (cachedFieldOptions.Count != 0)
            cachedField.CachedFieldOptions = this.SerializeObject(cachedFieldOptions);

              return cachedField;
        }