public IHttpActionResult PostKH_LOAI(KH_LOAI kH_LOAI) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.KH_LOAI.Add(kH_LOAI); try { db.SaveChanges(); } catch (DbUpdateException) { if (KH_LOAIExists(kH_LOAI.MA_LOAI_KHACH)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = kH_LOAI.MA_LOAI_KHACH }, kH_LOAI)); }
public IHttpActionResult PutKH_LOAI(string id, KH_LOAI kH_LOAI) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != kH_LOAI.MA_LOAI_KHACH) { return(BadRequest()); } db.Entry(kH_LOAI).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!KH_LOAIExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetKH_LOAI(string id) { KH_LOAI kH_LOAI = db.KH_LOAI.Find(id); if (kH_LOAI == null) { return(NotFound()); } return(Ok(kH_LOAI)); }
public IHttpActionResult DeleteKH_LOAI(string id) { KH_LOAI kH_LOAI = db.KH_LOAI.Find(id); if (kH_LOAI == null) { return(NotFound()); } db.KH_LOAI.Remove(kH_LOAI); db.SaveChanges(); return(Ok(kH_LOAI)); }