public IHttpActionResult PutCertificatedImage(int id, CertificatedImage certificatedImage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != certificatedImage.Id) { return(BadRequest()); } db.Entry(certificatedImage).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CertificatedImageExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCertificatedImage(int id) { CertificatedImage certificatedImage = db.CertificatedImages.Find(id); if (certificatedImage == null) { return(NotFound()); } return(Ok(certificatedImage)); }
public IHttpActionResult PostCertificatedImage(CertificatedImage certificatedImage) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CertificatedImages.Add(certificatedImage); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = certificatedImage.Id }, certificatedImage)); }
public IHttpActionResult DeleteCertificatedImage(int id) { CertificatedImage certificatedImage = db.CertificatedImages.Find(id); if (certificatedImage == null) { return(NotFound()); } db.CertificatedImages.Remove(certificatedImage); db.SaveChanges(); return(Ok(certificatedImage)); }