public Form Map(CreateOrEditViewModel createOrEdit)
        {
            Form form = new Form();

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

              form.Code = createOrEdit.Code;
              form.Email = createOrEdit.Email;
              return form;
        }
 public FormViewModel Build(Form form)
 {
     return new FormViewModel()
       {
     Id = form.Id,
     Name = this.GetObjectLocalizationValue(form.NameId),
     Fields = this.handler.Storage.GetRepository<IFieldRepository>().FilteredByFormId(form.Id).Select(
       f => new FieldViewModelBuilder(this.handler).Build(f)
     )
       };
 }
Пример #3
0
        public void CacheForm(Form form)
        {
            foreach (Culture culture in this.handler.Storage.GetRepository<ICultureRepository>().All())
              {
            CachedForm cachedForm = this.handler.Storage.GetRepository<ICachedFormRepository>().WithKey(culture.Id, form.Id);

            if (cachedForm == null)
              this.handler.Storage.GetRepository<ICachedFormRepository>().Create(this.CacheForm(culture, form));

            else
            {
              CachedForm temp = this.CacheForm(culture, form);

              cachedForm.Code = temp.Code;
              cachedForm.Name = temp.Name;
              cachedForm.CachedFields = temp.CachedFields;
              this.handler.Storage.GetRepository<ICachedFormRepository>().Edit(cachedForm);
            }
              }

              this.handler.Storage.Save();
        }
Пример #4
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;
        }