コード例 #1
0
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            Variable variable = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IVariableRepository>().Create(variable);

            else this.Storage.GetRepository<IVariableRepository>().Edit(variable);

            this.Storage.Save();
            return this.RedirectToAction("Index", "Configurations");
              }

              return this.CreateRedirectToSelfResult();
        }
コード例 #2
0
        public Variable Map(CreateOrEditViewModel createOrEdit)
        {
            Variable variable = new Variable();

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

            else
            {
                variable.SectionId = createOrEdit.SectionId;
            }

            variable.Code     = createOrEdit.Code;
            variable.Name     = createOrEdit.Name;
            variable.Value    = createOrEdit.Value;
            variable.Position = createOrEdit.Position;
            return(variable);
        }