public async Task <IActionResult> PutCommentComments(Guid id, CommentComments commentComments)
        {
            if (id != commentComments.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,OldComment,NewComment")] CommentComments commentComments)
        {
            if (id != commentComments.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(commentComments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentCommentsExists(commentComments.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NewComment"] = new SelectList(_context.Comments, "Id", "Id", commentComments.NewComment);
            ViewData["OldComment"] = new SelectList(_context.Comments, "Id", "Id", commentComments.OldComment);
            return(View(commentComments));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,OldComment,NewComment")] CommentComments commentComments)
        {
            if (ModelState.IsValid)
            {
                commentComments.Id = Guid.NewGuid();
                _context.Add(commentComments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NewComment"] = new SelectList(_context.Comments, "Id", "Id", commentComments.NewComment);
            ViewData["OldComment"] = new SelectList(_context.Comments, "Id", "Id", commentComments.OldComment);
            return(View(commentComments));
        }
        public async Task <ActionResult <CommentComments> > PostCommentComments(CommentComments commentComments)
        {
            _context.CommentComments.Add(commentComments);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CommentCommentsExists(commentComments.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetCommentComments", new { id = commentComments.Id }, commentComments));
        }