public IHttpActionResult PutTheLoaiAnh(int id, TheLoaiAnh theLoaiAnh) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != theLoaiAnh.IDTheLoaiAnh) { return(BadRequest()); } db.Entry(theLoaiAnh).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TheLoaiAnhExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTheLoaiAnh(int id) { TheLoaiAnh theLoaiAnh = db.TheLoaiAnhs.Find(id); if (theLoaiAnh == null) { return(NotFound()); } return(Ok(theLoaiAnh)); }
public IHttpActionResult PostTheLoaiAnh(TheLoaiAnh theLoaiAnh) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TheLoaiAnhs.Add(theLoaiAnh); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = theLoaiAnh.IDTheLoaiAnh }, theLoaiAnh)); }
public IHttpActionResult DeleteTheLoaiAnh(int id) { TheLoaiAnh theLoaiAnh = db.TheLoaiAnhs.Find(id); if (theLoaiAnh == null) { return(NotFound()); } db.TheLoaiAnhs.Remove(theLoaiAnh); db.SaveChanges(); return(Ok(theLoaiAnh)); }