public string CategoryUpdate(JObject json) { var model = JsonToObject <SYS_DicCategory>(json); using (NERPEntities db = new NERPEntities()) { db.SYS_DicCategory.Attach(model); db.Entry(model).State = EntityState.Modified; return((db.SaveChanges() > 0) ? "修改成功!" : "修改失败"); } }
public int Update(JObject json) { var model = JsonToObject <SYS_FunctionItem>(json); model.FI_CreatedOn = DateTime.Now; using (NERPEntities db = new NERPEntities()) { db.SYS_FunctionItem.Attach(model); db.Entry(model).State = EntityState.Modified; return((db.SaveChanges() > 0) ? 1 : -2); //成功1,失败-2 } }