Example #1
0
        public BroadcastResult Handle(AddLikeCommand command)
        {
            var likeTarget         = command.Context.Value;
            var likeTargetEntityId = likeTarget.EntityId.Value;

            switch (likeTarget.Type.ToInt())
            {
            case (int)ContextType.Comment:
                var commentsTarget = command.Context.GetCommentsTarget();

                if (ContextExtensions.HasFlagScalar(commentsTarget.Type, ContextType.Activity | ContextType.PagePromotion | ContextType.ContentPage))
                {
                    var service = _activitiesServiceFactory.GetNotifyableService(commentsTarget.EntityId.Value);
                    service.Notify(likeTargetEntityId, NotificationTypeEnum.CommentLikeAdded);
                }
                break;

            case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity):
                var notifiableService = _activitiesServiceFactory.GetNotifyableService(likeTargetEntityId);

                notifiableService.Notify(likeTargetEntityId, NotificationTypeEnum.ActivityLikeAdded);
                break;
            }

            return(BroadcastResult.Success);
        }
        public BroadcastResult Handle(AddCommentCommand command)
        {
            var commentsTarget         = command.Context.GetCommentsTarget();
            var commentsTargetEntityId = commentsTarget.EntityId.Value;

            if (ContextExtensions.HasFlagScalar(commentsTarget.Type, ContextType.Activity | ContextType.PagePromotion | ContextType.ContentPage))
            {
                var notifiableService = _activitiesServiceFactory.GetNotifyableService(commentsTargetEntityId);

                var notificationType = command.CreateDto.ParentId.HasValue ?
                                       NotificationTypeEnum.CommentReplied :
                                       NotificationTypeEnum.CommentAdded;

                notifiableService.Notify(command.CreateDto.ParentId ?? command.CreateDto.Id, notificationType);
            }

            return(BroadcastResult.Success);
        }
Example #3
0
        public BroadcastResult Handle(AddCommentCommand command)
        {
            var commentsTargetEntityId = command.TargetId;

            //var isHasFlag = command.TargetType.Is(IntranetEntityTypeEnum.ContentPage, IntranetEntityTypeEnum.News,
            //                                                IntranetEntityTypeEnum.Social, IntranetEntityTypeEnum.Events);

            //if (!isHasFlag)
            //    return BroadcastResult.Success;

            var notifiableService = _activitiesServiceFactory.GetNotifyableService(commentsTargetEntityId);

            var notificationType = command.CreateDto.ParentId.HasValue ?
                                   NotificationTypeEnum.CommentReplied :
                                   NotificationTypeEnum.CommentAdded;

            notifiableService.Notify(command.CreateDto.ParentId ?? command.CreateDto.Id, notificationType);

            return(BroadcastResult.Success);
        }
        public BroadcastResult Handle(AddLikeCommand command)
        {
            var likeTargetEntityId = command.EntityId;

            switch (command.EntityType)
            {
            case IntranetEntityTypeEnum.Comment:
                var service = _activitiesServiceFactory.GetNotifyableService(command.EntityId);
                service.Notify(likeTargetEntityId, NotificationTypeEnum.CommentLikeAdded);
                break;

            case IntranetEntityTypeEnum type when type.Is(IntranetEntityTypeEnum.News, IntranetEntityTypeEnum.Social, IntranetEntityTypeEnum.Events):
                var notifiableService = _activitiesServiceFactory.GetNotifyableService(likeTargetEntityId);

                notifiableService.Notify(likeTargetEntityId, NotificationTypeEnum.ActivityLikeAdded);
                break;
            }

            return(BroadcastResult.Success);
        }