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;
        }
Esempio n. 2
0
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            Form form = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            this.CreateOrEditEntityLocalizations(form);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IFormRepository>().Create(form);

            else this.Storage.GetRepository<IFormRepository>().Edit(form);

            this.Storage.Save();
            new CacheManager(this).CacheForm(form);
            return this.RedirectToAction("Index");
              }

              return this.CreateRedirectToSelfResult();
        }