public IHttpActionResult PostLyDoChi(LyDoChi lyDoChi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.LyDoChis.Add(lyDoChi); try { db.SaveChanges(); } catch (DbUpdateException) { if (LyDoChiExists(lyDoChi.IDLyDoChi)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = lyDoChi.IDLyDoChi }, lyDoChi)); }
public IHttpActionResult PutLyDoChi(string id, LyDoChi lyDoChi) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lyDoChi.IDLyDoChi) { return(BadRequest()); } db.Entry(lyDoChi).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LyDoChiExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetLyDoChi(string id) { LyDoChi lyDoChi = db.LyDoChis.Find(id); if (lyDoChi == null) { return(NotFound()); } return(Ok(lyDoChi)); }
public LyDoChi LayLyDoChi(long id) { DataTable tbl = factory.LayLyDoChi(id); LyDoChi lydo = new LyDoChi(); if (tbl.Rows.Count > 0) { lydo.Id = Convert.ToInt64(tbl.Rows[0]["ID"]); lydo.LyDo = Convert.ToString(tbl.Rows[0]["LY_DO"]); } return(lydo); }
public IHttpActionResult DeleteLyDoChi(string id) { LyDoChi lyDoChi = db.LyDoChis.Find(id); if (lyDoChi == null) { return(NotFound()); } db.LyDoChis.Remove(lyDoChi); db.SaveChanges(); return(Ok(lyDoChi)); }