Exemplo n.º 1
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.º 2
0
        public virtual async Task <RatingDto> CreateAsync(string entityType, string entityId,
                                                          CreateUpdateRatingInput input)
        {
            var userId = CurrentUser.GetId();
            var user   = await CmsUserLookupService.GetByIdAsync(userId);

            var rating = await RatingManager.SetStarAsync(user, entityType, entityId, input.StarCount);

            return(ObjectMapper.Map <Rating, RatingDto>(rating));
        }