public IHttpActionResult PutNews(int id, News news) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != news.Id) { return(BadRequest()); } db.Entry(news).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NewsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "userid,password,zt,username,workcode,Email,phoneNumber,address,departmentid,company,login")] UserMSG userMSG) { if (ModelState.IsValid) { db.Entry(userMSG).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userMSG)); }
/// <summary> /// 删除 /// </summary> /// <param name="t"></param> /// <returns></returns> public int Update(T t) { dBContext.Entry(t).State = EntityState.Modified; return(dBContext.SaveChanges()); }