Exemplo n.º 1
0
 public ActionResult AddSetting(SysSetting model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.SysSettings.Add(model);
             db.SaveChanges();
             return Redirect("/Admin/System/Setting");
         }
         catch
         {
             ModelState.AddModelError("", "添加系统参数出错!");
         }
     }
     else
     {
         ModelState.AddModelError("", "你填写的信息有误");
     }
     return View();
 }
Exemplo n.º 2
0
        public ActionResult SettingEdit(SysSetting model)
        {
            if(ModelState.IsValid)
            {
                try
                {
                    var settting = db.SysSettings.Find(model.ID);
                    settting.Key = model.Key;
                    settting.Value = model.Value;
                    db.SaveChanges();
                    return Redirect("/Admin/System/Setting");
                }
                catch
                {
                    ModelState.AddModelError("", "修改失败!");
                }

            }
            else
            {
                ModelState.AddModelError("","填写信息错误");
            }
            return View();
        }