Exemple #1
0
        public IHttpActionResult PutCustomImage(int id, CustomImage customImage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customImage.ImageId)
            {
                return(BadRequest());
            }

            db.Entry(customImage).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomImageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public CustomImage UpsertCustomImage(CustomImage customImage, CustomImageDBEntities2 db)
        {
            using (db)
            {
                if (customImage.ImageId == default(int))
                {
                    db.CustomImages.Add(customImage);
                }
                else
                {
                    db.Entry(customImage).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(customImage);
            }
        }