public IHttpActionResult PutUserInfo(int id, UserInfo userInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userInfo.ID) { return(BadRequest()); } db.Entry(userInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCategory(int id, Category category) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != category.ID) { return(BadRequest()); } db.Entry(category).State = EntityState.Modified; try { category.User_ID = this.GetUser(db).ID; db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID,Title")] TestTable testTable) { if (ModelState.IsValid) { db.Entry(testTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testTable)); }