public IHttpActionResult PostBOMONTRUNGTAM(BOMONTRUNGTAM bOMONTRUNGTAM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BOMONTRUNGTAMs.Add(bOMONTRUNGTAM); try { db.SaveChanges(); } catch (DbUpdateException) { if (BOMONTRUNGTAMExists(bOMONTRUNGTAM.MaBm)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = bOMONTRUNGTAM.MaBm }, bOMONTRUNGTAM)); }
public IHttpActionResult PutBOMONTRUNGTAM(int id, BOMONTRUNGTAM bOMONTRUNGTAM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bOMONTRUNGTAM.MaBm) { return(BadRequest()); } db.Entry(bOMONTRUNGTAM).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BOMONTRUNGTAMExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// POST: api/BoMonTrungTam public void Post([FromBody] BOMONTRUNGTAM bOMONTRUNGTAM) { using (QLGVEntities db = new QLGVEntities()) { db.BOMONTRUNGTAMs.Add(bOMONTRUNGTAM); db.SaveChanges(); } }
public IHttpActionResult GetBOMONTRUNGTAM(int id) { BOMONTRUNGTAM bOMONTRUNGTAM = db.BOMONTRUNGTAMs.Find(id); if (bOMONTRUNGTAM == null) { return(NotFound()); } return(Ok(bOMONTRUNGTAM)); }
public IHttpActionResult DeleteBOMONTRUNGTAM(int id) { BOMONTRUNGTAM bOMONTRUNGTAM = db.BOMONTRUNGTAMs.Find(id); if (bOMONTRUNGTAM == null) { return(NotFound()); } db.BOMONTRUNGTAMs.Remove(bOMONTRUNGTAM); db.SaveChanges(); return(Ok(bOMONTRUNGTAM)); }
// PUT: api/BoMonTrungTam/5 public void Put(int id, [FromBody] BOMONTRUNGTAM bOMONTRUNGTAM) { using (QLGVEntities db = new QLGVEntities()) { var s = db.BOMONTRUNGTAMs.SingleOrDefault(x => x.MaBm == id); if (s != null) { s.MaBm = bOMONTRUNGTAM.MaBm; s.TenBM = bOMONTRUNGTAM.TenBM; s.DiaChi = bOMONTRUNGTAM.DiaChi; s.Fax = bOMONTRUNGTAM.Fax; s.SDT = bOMONTRUNGTAM.SDT; s.Email = bOMONTRUNGTAM.Email; db.SaveChanges(); } else { } } }