示例#1
0
 private static Comment Map(CommentCreateDto dto) =>
 new Comment
 {
     Id         = dto.Id,
     ActivityId = dto.ActivityId,
     UserId     = dto.UserId,
     Text       = dto.Text,
     ParentId   = dto.ParentId
 };
        public virtual CommentModel Create(CommentCreateDto dto)
        {
            var entity = Map(dto);

            entity.CreatedDate = entity.ModifyDate = DateTime.Now.ToUniversalTime();
            _commentsRepository.Add(entity);
            if (dto.LinkPreviewId.HasValue)
            {
                _commentLinkPreviewService.AddLinkPreview(entity.Id, dto.LinkPreviewId.Value);
            }
            return(entity.Map <CommentModel>());
        }
        private Comment Map(CommentCreateDto dto)
        {
            var entity = new Comment
            {
                Id         = dto.Id,
                ActivityId = dto.ActivityId,
                UserId     = dto.UserId,
                Text       = dto.Text,
                ParentId   = dto.ParentId
            };

            return(entity);
        }