public IHttpActionResult PutXeDangKy(int id, XeDangKy xeDangKy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != xeDangKy.ma_dang_ky) { return(BadRequest()); } db.Entry(xeDangKy).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!XeDangKyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetXeDangKy(int id) { XeDangKy xeDangKy = db.XeDangKies.Find(id); if (xeDangKy == null) { return(NotFound()); } return(Ok(xeDangKy)); }
public IHttpActionResult PostXeDangKy(XeDangKy xeDangKy) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.XeDangKies.Add(xeDangKy); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = xeDangKy.ma_dang_ky }, xeDangKy)); }
public IHttpActionResult DeleteXeDangKy(int id) { XeDangKy xeDangKy = db.XeDangKies.Find(id); if (xeDangKy == null) { return(NotFound()); } db.XeDangKies.Remove(xeDangKy); db.SaveChanges(); return(Ok(xeDangKy)); }