Exemple #1
0
        public async Task <IActionResult> Update([FromRoute] string id, [FromBody] CommentUpdateDto dto)
        {
            var userId  = User.GetUserId();
            var comment = await _repo.GetComment(id);

            if (comment.CreatedById != userId)
            {
                return(Unauthorized());
            }

            comment.Text = dto.Text;

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest());
        }