// PUT api/Image/5 public IHttpActionResult PutImage(int id, ScriptImage image) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != image.ScriptImageID) { return(BadRequest()); } db.Entry(image).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ImageExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetScriptProjectImage(int id) { ScriptImage image = db.ScriptImages.Find(id); if (image == null) { return(NotFound()); } return(Ok(image)); }
public IHttpActionResult PostImage(ScriptImage image) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ScriptImages.Add(image); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = image.ScriptImageID }, image)); }
public IHttpActionResult DeleteImage(int id) { ScriptImage image = db.ScriptImages.Find(id); if (image == null) { return(NotFound()); } db.ScriptImages.Remove(image); db.SaveChanges(); return(Ok(image)); }