public CommentDTO Map(Comment comment)
 {
     return new CommentDTO
         {
             CommentId = comment.CommentId,
             CommentText = comment.Text,
             CreatedAt = comment.CreatedAt,
             ModifiedAt = comment.ModifiedAt,
             Author = _userToUserDtoMapper.Map(comment.User)
         };
 }
        public CommentDTO CreateComment(BlogContext context, string sessionToken, int postId, string commentText)
        {
            var user = _authenticationService.GetUserBySessionToken(context, sessionToken);

            var post = context.Posts.SingleOrDefault(p => p.PostId == postId);
            if (post == null)
            {
                throw new NoSuchPostException();
            }

            var comment = new Comment
                {
                    Text = commentText,
                    CreatedAt = DateTime.UtcNow,
                    ModifiedAt = null,
                    Post = post,
                    User = user
                };

            context.Comments.Add(comment);
            context.SaveChanges();

            return _commentToCommentDtoMapper.Map(comment);
        }