Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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);
        }