public async Task <PortfolioCommentDTO> CreatePortfolioComment(PortfolioCommentToCreateDTO commentToCreate)
        {
            PortfolioComment comment = ConvertCommentToCreate(commentToCreate);

            comment.PostedOn = DateTime.Now.Date;
            return(ConvertComment(await _genericRepo.AddAsync(comment)));
        }
        private PortfolioComment ConvertCommentToCreate(PortfolioCommentToCreateDTO x)
        {
            if (x == null)
            {
                return(null);
            }

            PortfolioComment comment = new PortfolioComment
            {
                UserId      = x.UserId,
                PortfolioId = x.PortfolioId,
                Message     = x.Message
            };

            return(comment);
        }
        public async Task <IActionResult> Put(PortfolioCommentToCreateDTO comment)
        {
            var portfolio = await _portfolioServices.GetPortfolioByIdAsync(comment.PortfolioId);

            if (portfolio == null)
            {
                return(StatusCode(400, "Portfolio with id " + comment.PortfolioId + " was not found."));
            }

            comment.Message = _javaScriptEncoder.Encode(_htmlEncoder.Encode(comment.Message));

            comment.UserId = Int32.Parse(this.User.FindFirstValue(ClaimTypes.NameIdentifier));
            var createdComment = await _commentServices.CreatePortfolioComment(comment);

            return(StatusCode(200));
        }