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 Create([Bind(Include = "userid,password,zt,username,workcode,Email,phoneNumber,address,departmentid,company,login")] UserMSG userMSG) { if (ModelState.IsValid) { db.UserMSG.Add(userMSG); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userMSG)); }
/// <summary> /// 增加信息 /// </summary> /// <param name="t"></param> /// <returns></returns> public int Add(T t) { dBContext.Set <T>().Add(t); return(dBContext.SaveChanges()); }