public IHttpActionResult PutApi_Data(int id, Api_Data api_Data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != api_Data.id) { return(BadRequest()); } db.Entry(api_Data).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Api_DataExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetApi_Data(int id) { Api_Data api_Data = db.Api_Data.Find(id); if (api_Data == null) { return(NotFound()); } return(Ok(api_Data)); }
public IHttpActionResult PostApi_Data(Api_Data api_Data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Api_Data.Add(api_Data); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = api_Data.id }, api_Data)); }
public IHttpActionResult DeleteApi_Data(int id) { Api_Data api_Data = db.Api_Data.Find(id); if (api_Data == null) { return(NotFound()); } db.Api_Data.Remove(api_Data); db.SaveChanges(); return(Ok(api_Data)); }