public async Task <bool> UpdateCommentAsync(CommentUpdateDTO commentUpdateDTO) { Preconditions.NotNull(commentUpdateDTO, nameof(commentUpdateDTO)); return(commentUpdateDTO.IsMain ? await UpdateMainCommentAsync(commentUpdateDTO) : await UpdateSubCommentAsync(commentUpdateDTO)); }
public ActionResult UpdateComment(int id, CommentUpdateDTO commentUpdateDTO) { var comment = _commentService.GetCommentById(id); if (comment == null) { return(NotFound()); } _mapper.Map(commentUpdateDTO, comment); _commentService.UpdateComment(comment); _commentService.SaveChanges(); return(NoContent()); }
public async Task <ActionResult <Comment> > update(int id, [FromBody] CommentUpdateDTO commentUpdateDTO) { if (id != commentUpdateDTO.CommentId || commentUpdateDTO == null) { return(BadRequest()); } var comment = _mapper.Map <Comment>(commentUpdateDTO); if (!await _commentRepository.UpdateAsync(comment)) { ModelState.AddModelError("", "Error encountered when saving to database, try again. If problem persists contact your administrator"); return(StatusCode(500, ModelState)); } return(NoContent()); }
private async Task <bool> UpdateSubCommentAsync(CommentUpdateDTO commentUpdateDTO) { var subCommentEntity = await _commentRepository.GetSubCommentByIdAsync(commentUpdateDTO.ID); if (subCommentEntity is null) { return(false); } if (!(await HasPermissionForUpdateOrDelete(subCommentEntity.ApplicationUserID))) { return(false); } _mapper.Map(commentUpdateDTO, subCommentEntity); var updatedSubComment = await _commentRepository.UpdateSubCommentAsync(subCommentEntity); return(updatedSubComment != null); }
public async Task <bool> UpdateCommentAsync(CommentUpdateDTO commentUpdateDTO) { return(await _httpService.PutHelperAsync <CommentUpdateDTO, bool>(CommentClientEndpoints.Update, commentUpdateDTO)); }
public async Task <ActionResult <bool> > Put([FromBody] CommentUpdateDTO commentUpdateDTO) { return(await _commentService.UpdateCommentAsync(commentUpdateDTO)); }