Exemplo n.º 1
0
        public virtual CommentModel Update(CommentEditDto dto)
        {
            var comment            = _commentsRepository.Get(dto.Id);
            var commentLinkPreview = _commentLinkPreviewService.GetCommentsLinkPreview(comment.Id);

            comment.ModifyDate = DateTime.Now.ToUniversalTime();
            comment.Text       = dto.Text;

            _commentsRepository.Update(comment);

            if (dto.LinkPreviewId.HasValue)
            {
                if (commentLinkPreview?.Id != dto.LinkPreviewId)
                {
                    _commentLinkPreviewService.UpdateLinkPreview(dto.Id, dto.LinkPreviewId.Value);
                }
            }
            else
            {
                _commentLinkPreviewService.RemovePreviewRelations(dto.Id);
            }

            return(comment.Map <CommentModel>());
        }