public IHttpActionResult PutKhachHang(string id, KhachHang khachHang) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != khachHang.MaKhachHang) { return(BadRequest()); } db.Entry(khachHang).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!KhachHangExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutSach(string id, Sach sach) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if (id != sach.MaSach) //{ // return BadRequest(); //} db.Entry(sach).State = EntityState.Modified; db.SaveChanges(); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SachExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }