public async Task <IActionResult> PutImage(long id, Image image)
        {
            if (id != image.Id)
            {
                return(BadRequest());
            }

            _context.Entry(image).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ImageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <IHttpActionResult> PutImage(int id, Image image)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ImageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "id,UserName,UserEmail,UserPassword")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult EditPost(Picture img)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(img).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(img));
 }