public async Task <IActionResult> PutComments(int id, BlogDataModel.Comments comments) { if (id != comments.CommentID) { return(BadRequest()); } _context.Entry(comments).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <BlogDataModel.Comments> > PostComments(BlogDataModel.Comments comments) { _context.Comments.Add(comments); await _context.SaveChangesAsync(); return(CreatedAtAction("GetComments", new { id = comments.CommentID }, comments)); }