public async Task <ActionResult <IEnumerable <CommentPostModel> > > GetListCommentPostModel(int id) { if (id <= 0) { return(NotFound()); } var commentPostModel = await _commentPostServices.GetPostByIdAsync(id); if (commentPostModel == null) { return(NotFound()); } return(commentPostModel.ToList()); }
private async Task <IEnumerable <CommentPostViewModel> > GetListCommentByIdPost(int idPost) { var commentList = new List <CommentPostViewModel>(); var listaComentarios = await _commentPostServices.GetPostByIdAsync(idPost); foreach (var comentario in listaComentarios) { var usuarioModel = await _usuarioServices.GetByIdAsync(comentario.IdentityUser); var(tempo, formato) = DefinirTempoPostagem(comentario.DataDoComment); commentList.Add(new CommentPostViewModel(comentario, usuarioModel, tempo, formato)); } return(commentList); }