public override IMappingExpression <Comment, CommentDto> CreateMap(IMapperConfigurationExpression cfg) { return(base.CreateMap(cfg) .ForMember(dto => dto.Avatar, map => map.MapFrom(comment => comment.User.Avatar)) .ForMember(dto => dto.Username, map => map.MapFrom(comment => comment.User.Username)) .ForMember(dto => dto.Answers, map => map.ResolveUsing(comment => _answerCommentMapper.Map(comment.Answers)))); }
public GetBestCommentsResponse GetBestComments(int postId, int count) { var comments = _commentRepository.GetBestComments(postId, count); var commentDtos = _answerCommentMapper.Map(comments); return(new GetBestCommentsResponse { Count = commentDtos.Count, CommentsList = commentDtos }); }