Пример #1
0
        public virtual void Editar(int id)
        {
            T entidade = photoSharingContext.Set <T>().Find(id);

            photoSharingContext.Entry(entidade).State = EntityState.Modified;
            photoSharingContext.SaveChanges();
        }
Пример #2
0
        public IHttpActionResult PutPhoto(int id, Photo photo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != photo.PhotoID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            List <Photo> photos = context.Photos.ToList();
            var          verif  = photos.Find(photo => photo.PhotoID == id);

            context.Entry(verif).State = EntityState.Deleted;
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "PhotoID,Title,ImageMimeType,Description,CreatedDate,UserName,PhotoFile")] Photo photo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(photo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(photo));
 }
Пример #5
0
 public ActionResult Edit([Bind(Include = "Id,Title,File,MimeType,Description,Username,CreateDate")] Photo photo)
 {
     if (ModelState.IsValid)
     {
         context.Entry(photo).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(photo));
 }
 public ActionResult Edit(Photo photo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(photo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(photo));
 }
Пример #7
0
        // PUT api/CommentApi/5
        public HttpResponseMessage PutComment(int id, Comment comment)
        {
            if (ModelState.IsValid && id == comment.CommentID)
            {
                db.Entry(comment).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }