示例#1
0
        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());
        }
示例#2
0
        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));
        }