public DataType Map(CreateOrEditViewModel createOrEdit)
        {
            DataType dataType = new DataType();

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

              dataType.JavaScriptEditorClassName = createOrEdit.JavaScriptEditorClassName;
              dataType.Name = createOrEdit.Name;
              dataType.Position = createOrEdit.Position;
              return dataType;
        }
Пример #2
0
        public DataType Map(CreateOrEditViewModel createOrEdit)
        {
            DataType dataType = new DataType();

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

            dataType.JavaScriptEditorClassName = createOrEdit.JavaScriptEditorClassName;
            dataType.Name     = createOrEdit.Name;
            dataType.Position = createOrEdit.Position;
            return(dataType);
        }
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            DataType dataType = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IDataTypeRepository>().Create(dataType);

            else this.Storage.GetRepository<IDataTypeRepository>().Edit(dataType);

            this.Storage.Save();
            return this.Redirect(this.Request.CombineUrl("/backend/datatypes"));
              }

              return this.CreateRedirectToSelfResult();
        }