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)
            )
              };
        }
Пример #2
0
        private CachedForm CacheForm(Culture culture, Form form)
        {
            List<CachedField> cachedFields = new List<CachedField>();

              foreach (Field field in this.handler.Storage.GetRepository<IFieldRepository>().FilteredByFormId(form.Id))
            cachedFields.Add(this.CacheField(culture, field));

              CachedForm cachedForm = new CachedForm();

              cachedForm.FormId = form.Id;
              cachedForm.CultureId = culture.Id;
              cachedForm.Code = form.Code;
              cachedForm.Name = this.GetLocalizationValue(culture.Id, form.NameId);

              if (cachedFields.Count != 0)
            cachedForm.CachedFields = this.SerializeObject(cachedFields);

              return cachedForm;
        }