Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public IHttpActionResult GetCertificatedImage(int id)
        {
            CertificatedImage certificatedImage = db.CertificatedImages.Find(id);

            if (certificatedImage == null)
            {
                return(NotFound());
            }

            return(Ok(certificatedImage));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }