public async Task <IActionResult> Edit([FromQuery] Guid id, [FromBody] CommentPutDto commentPutDto)
        {
            if (id != commentPutDto.ID)
            {
                return(BadRequest());
            }

            await commentService.UpdateAsync(commentPutDto);

            return(NoContent());
        }
Example #2
0
        public async Task EditAsync(CommentPutDto commentPutDto)
        {
            var commentToEdit = await _mongoRepository.FindByIdAsync(commentPutDto.Id);

            if (commentToEdit == null)
            {
                throw new ArgumentNullException($"Comment with id {commentPutDto.Id} does not exist");
            }
            commentToEdit.Text = commentPutDto.Text;

            await _mongoRepository.ReplaceOneAsync(commentToEdit);
        }
Example #3
0
        public async Task <bool> UpdateAsync(CommentPutDto proPlanPutDto)
        {
            CommentPutDtoValidator validator = new CommentPutDtoValidator();
            ValidationResult       results   = validator.Validate(proPlanPutDto);

            if (!results.IsValid)
            {
                throw new ValidationException("proPlanPutDTO", string.Join(". ", results.Errors));
            }

            Comment project = await _repository.GetByIdAsync(proPlanPutDto.ID);

            if (project == null)
            {
                throw new NotFoundException($"The server can not find the requested Comment with ID: {proPlanPutDto.ID}");
            }

            return(await _repository.UpdateAsync(mapper.Map <Comment>(proPlanPutDto)) != null);
        }
Example #4
0
        public async Task <IActionResult> Edit(CommentPutDto commentPutDto)
        {
            await _commentService.EditAsync(commentPutDto);

            return(NoContent());
        }