コード例 #1
0
        public ActionResult Edit(AttributeModel model)
        {
            var attribute = _attributeRepository.GetById(model.Id);

            if (ModelState.IsValid)
            {
                if ((model.ControlType == AttributeControlType.DropDownList ||
                     model.ControlType == AttributeControlType.MultiSelectList) &&
                    (model.DataSource == AttributeDataSource.CSV))
                {
                    //No need to update for this case.
                }
                else
                {
                    model.CsvTextList  = null;
                    model.CsvValueList = null;
                }
                attribute = model.ToEntity(attribute);
                //always set IsNew to false when saving
                attribute.IsNew = false;

                _attributeRepository.Update(attribute);

                //commit all changes
                this._dbContext.SaveChanges();

                //notification
                SuccessNotification(_localizationService.GetResource("Record.Saved"));
                return(new NullJsonResult());
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }