public FieldOption Map(CreateOrEditViewModel createOrEdit)
        {
            FieldOption fieldOption = new FieldOption();

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

              else fieldOption.FieldId = createOrEdit.FieldId;

              fieldOption.Position = createOrEdit.Position;
              return fieldOption;
        }
示例#2
0
        public FieldOption Map(CreateOrEditViewModel createOrEdit)
        {
            FieldOption fieldOption = new FieldOption();

            if (createOrEdit.Id != null)
            {
                fieldOption = this.handler.Storage.GetRepository <IFieldOptionRepository>().WithKey((int)createOrEdit.Id);
            }

            else
            {
                fieldOption.FieldId = createOrEdit.FieldId;
            }

            fieldOption.Position = createOrEdit.Position;
            return(fieldOption);
        }
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            FieldOption fieldOption = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            this.CreateOrEditEntityLocalizations(fieldOption);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IFieldOptionRepository>().Create(fieldOption);

            else this.Storage.GetRepository<IFieldOptionRepository>().Edit(fieldOption);

            this.Storage.Save();
            this.CacheForm(fieldOption);
            return this.RedirectToAction("Index", "Forms");
              }

              return this.CreateRedirectToSelfResult();
        }