public IHttpActionResult PutDM_KhachHang(int id, DM_KhachHang dM_KhachHang) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dM_KhachHang.id) { return(BadRequest()); } db.Entry(dM_KhachHang).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DM_KhachHangExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetDM_KhachHang(int id) { DM_KhachHang dM_KhachHang = db.DM_KhachHang.Find(id); if (dM_KhachHang == null) { return(NotFound()); } return(Ok(dM_KhachHang)); }
public IHttpActionResult PostDM_KhachHang(DM_KhachHang dM_KhachHang) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DM_KhachHang.Add(dM_KhachHang); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = dM_KhachHang.id }, dM_KhachHang)); }
public IHttpActionResult DeleteDM_KhachHang(int id) { DM_KhachHang dM_KhachHang = db.DM_KhachHang.Find(id); if (dM_KhachHang == null) { return(NotFound()); } db.DM_KhachHang.Remove(dM_KhachHang); db.SaveChanges(); return(Ok(dM_KhachHang)); }