public FieldViewModel Build(Field field)
 {
     return new FieldViewModel()
       {
     Id = field.Id,
     Name = this.handler.Storage.GetRepository<ILocalizationRepository>().FilteredByDictionaryId(field.NameId).First().Value,
     FieldOptions = this.handler.Storage.GetRepository<IFieldOptionRepository>().FilteredByFieldId(field.Id).Select(
       fo => new FieldOptionViewModelBuilder(this.handler).Build(fo)
     )
       };
 }
 public FieldViewModel Build(Field field)
 {
     return new FieldViewModel()
       {
     Id = field.Id,
     FieldType = new FieldTypeViewModelBuilder(this.handler).Build(this.handler.Storage.GetRepository<IFieldTypeRepository>().WithKey(field.FieldTypeId)),
     Name = this.GetObjectLocalizationValue(field.NameId),
     FieldOptions = this.handler.Storage.GetRepository<IFieldOptionRepository>().FilteredByFieldId(field.Id).Select(
       fi => new FieldOptionViewModelBuilder(this.handler).Build(fi)
     )
       };
 }
        public Field Map(CreateOrEditViewModel createOrEdit)
        {
            Field field = new Field();

              if (createOrEdit.Id != null)
            field = this.handler.Storage.GetRepository<IFieldRepository>().WithKey((int)createOrEdit.Id);

              else field.FormId = createOrEdit.FormId;

              field.FieldTypeId = createOrEdit.FieldTypeId;
              field.Position = createOrEdit.Position;
              return field;
        }
        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;
        }