public ActionResult Edit([Bind(Include = "id,module_key,sub_key,value,sub_value,desc,extra")] Models.setting setting) { if (ModelState.IsValid) { db.Entry(setting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(setting)); }
public ActionResult Create([Bind(Include = "id,module_key,sub_key,value,sub_value,desc,extra")] Models.setting setting) { if (ModelState.IsValid) { setting.id = Guid.NewGuid(); db.settings.Add(setting); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(setting)); }
public ActionResult Setting(Guid?id, FormCollection collection) { try { if (id != null) { var settings = db.settings.Find(id); settings.value = collection[TM.Common.Config.sub_key.form_use_label]; } else { var settings = new Models.setting(); settings.id = Guid.NewGuid(); settings.module_key = Authentication.Auth.AuthUser.id.ToString(); settings.sub_key = TM.Common.Config.sub_key.form_use_label; settings.value = collection[TM.Common.Config.sub_key.form_use_label]; db.settings.Add(settings); } db.SaveChanges(); this.success("Cập nhật thông tin thành công"); } catch (Exception) { this.danger("Cập nhật thông tin thất bại"); } return(RedirectToAction("Setting")); }