Ejemplo n.º 1
0
        public async Task <ActionResult <CommentCreateDto> > CreateCommentAsync(CommentCreateDto comment)
        {
            //try
            //{
            var commentModel = _mapper.Map <Comment>(comment);
            await _repository.CreateCommentAsync(commentModel);

            await _repository.SaveChangesAsync();

            var commentReadDto = _mapper.Map <CommentReadDto>(commentModel);

            return(CreatedAtRoute(nameof(GetCommentByIdAsync), new { Id = commentReadDto.Id }, commentReadDto));
            //}
            //catch (Exception err)
            //{

            //     return StatusCode(500, err.InnerException.Message);
            //}
        }