public async Task <IActionResult> DeleteCommentByIdAsync(string idComment) { try { GetCommentByIdViewModel commentByIdViewModel = new GetCommentByIdViewModel(idComment); var getByIdrequest = commentByIdViewModel.BuilderRequest(commentByIdViewModel); result = await _commentService.DeleteByIdAsync(getByIdrequest.IdComment); if (!result) { return(BadRequest("The Id " + idComment + " Doesn't exist.")); } } catch (Exception ex) { return(NotFound(ex.Message)); } return(Ok(MessageGeneral.DeleteSuccess)); }
public async Task <IActionResult> GetCommentByIdAsync(string idComment) { try { GetCommentByIdViewModel commentByIdViewModel = new GetCommentByIdViewModel(idComment); var getByIdrequest = commentByIdViewModel.BuilderRequest(commentByIdViewModel); commentDto = await _commentService.GetCommentByIdAsync(getByIdrequest.IdComment); if (commentDto is null) { return(BadRequest(MessageGeneral.DontExist)); } } catch (Exception ex) { return(NotFound(ex.Message)); } return(Ok(commentDto)); }