コード例 #1
0
        public ActionResult Edit(SettingModel model)
        {
            if (ModelState.IsValid)
            {
                var entity = _settingService.GetSettingById(model.Id);

                if (entity == null)
                {
                    return(RedirectToAction("List"));
                }

                entity = model.ToEntity(entity);
                _settingService.UpdateSetting(entity);
                return(RedirectToAction("List").WithSuccess($"Setting - {entity.Name} - was updated successfully."));
            }
            return(View(model));
        }
コード例 #2
0
        public JsonResult Update(SettingModel model)
        {
            Setting currentSetting;

            if (model.Id > 0)
            {
                currentSetting = _settingService.GetSettingById(model.Id);
            }
            else
            {
                currentSetting = new Setting();
            }
            model.ToEntity(currentSetting);
            var rs = _settingService.AddOrUpdate(currentSetting);

            return(Json(rs));
        }