public async Task <IActionResult> PutComment(int id, Comment comment) { if (id != comment.Id) { return(BadRequest()); } _context.Entry(comment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// PUT api/Comment/5 public IHttpActionResult PutComment(int id, Comment comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != comment.Id) { return(BadRequest()); } db.Entry(comment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CommentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID,Text,CommentDate,ProfileID,PostID")] PostComment postComment) { if (ModelState.IsValid) { db.Entry(postComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(postComment)); }
public ActionResult Edit([Bind(Include = "CommentID,ReviewID,Description,Name,EMail")] Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(comment)); }
public async Task <IActionResult> EditComment([FromRoute] long id, [FromBody] Comment comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dbComment = await _commentContext.Comment.SingleOrDefaultAsync(c => c.CommentID == id); if (comment.UserID != dbComment.UserID) { return(Unauthorized()); } dbComment.CommentText = comment.CommentText; _commentContext.Entry(dbComment).State = EntityState.Modified; await _commentContext.SaveChangesAsync(); return(Ok("Comment updated successfully")); }
public async Task <IActionResult> PutCommentItem(long id, CommentItem item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> PutComment(int midex, string userid, Comment comment) { if (midex != comment.midex) { return(BadRequest()); } _context.Entry(comment).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task AddDownVote_AddsOneTo_DownVoteCount() { var comment = new Comment { Text = "IncrementCommentCountTest", User = "******" }; using (var context = new CommentContext(Options)) { context.Comments.Add(comment); await context.SaveChangesAsync(); await context.AddDownVoteAsync(comment.Id); await context.Entry(comment).ReloadAsync(); Assert.Equal(1, comment.DownVoteCount); } }
public void Update(Comment comment) { _context.Entry(comment).State = EntityState.Modified; _context.SaveChanges(); }
public ActionResult EditComment(Comment comment) { com.Entry(comment).State = EntityState.Modified; com.SaveChanges(); return(RedirectToAction("Comments")); }
public void Edit(Comment comment) { context.Entry(comment).State = System.Data.Entity.EntityState.Modified; }