Exemplo n.º 1
0
        public virtual async Task <CommentDto> CreateAsync(CreateCommentInput input)
        {
            var user = await CmsUserLookupService.FindByIdAsync(CurrentUser.GetId());

            if (user == null)
            {
                throw new BusinessException(message: "User Not found!");
            }

            var comment = await CommentRepository.InsertAsync(new Comment(
                                                                  GuidGenerator.Create(),
                                                                  input.EntityType,
                                                                  input.EntityId,
                                                                  input.Text,
                                                                  input.RepliedCommentId,
                                                                  user.Id,
                                                                  CurrentTenant.Id
                                                                  ));

            return(ObjectMapper.Map <Comment, CommentDto>(comment));
        }
Exemplo n.º 2
0
 public Task <CommentDto> CreateAsync(CreateCommentInput input)
 {
     return(CommentPublicAppService.CreateAsync(input));
 }
Exemplo n.º 3
0
        public virtual async Task <CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
        {
            var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId());

            if (input.RepliedCommentId.HasValue)
            {
                await CommentRepository.GetAsync(input.RepliedCommentId.Value);
            }

            var comment = await CommentRepository.InsertAsync(
                new Comment(
                    GuidGenerator.Create(),
                    entityType,
                    entityId,
                    input.Text,
                    input.RepliedCommentId,
                    user.Id,
                    CurrentTenant.Id
                    )
                );


            await UnitOfWorkManager.Current.SaveChangesAsync();

            await DistributedEventBus.PublishAsync(new CreatedCommentEvent
            {
                Id = comment.Id
            });

            return(ObjectMapper.Map <Comment, CommentDto>(comment));
        }
Exemplo n.º 4
0
 public Task <CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
 {
     return(CommentPublicAppService.CreateAsync(entityType, entityId, input));
 }
Exemplo n.º 5
0
        public virtual async Task <CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input)
        {
            var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId());

            var comment = await CommentRepository.InsertAsync(
                new Comment(
                    GuidGenerator.Create(),
                    entityType,
                    entityId,
                    input.Text,
                    input.RepliedCommentId,
                    user.Id,
                    CurrentTenant.Id
                    )
                );

            return(ObjectMapper.Map <Comment, CommentDto>(comment));
        }