public async Task<Unit> Handle(EnableMeetingCommentingConfigurationCommand command, CancellationToken cancellationToken)
        {
            var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(new MeetingId(command.MeetingId));
            if (meetingCommentingConfiguration == null)
            {
                throw new InvalidCommandException(new List<string> { "Meeting commenting configuration for enabling commenting must exist." });
            }

            var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId));

            var meetingGroup = await _meetingGroupRepository.GetByIdAsync(meeting.GetMeetingGroupId());

            meetingCommentingConfiguration.EnableCommenting(_memberContext.MemberId, meetingGroup);

            return Unit.Value;
        }
        public async Task <Unit> Handle(EditMeetingCommentCommand command, CancellationToken cancellationToken)
        {
            var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(command.MeetingCommentId));

            if (meetingComment == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "Meeting comment for editing must exist."
                });
            }

            var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(meetingComment.GetMeetingId());

            meetingComment.Edit(_memberContext.MemberId, command.EditedComment, meetingCommentingConfiguration);

            return(Unit.Value);
        }
        public async Task <Guid> Handle(AddMeetingCommentCommand command, CancellationToken cancellationToken)
        {
            var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId));

            if (meeting == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "Meeting for adding comment must exist."
                });
            }

            var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(new MeetingId(command.MeetingId));

            var meetingComment = meeting.AddComment(_memberContext.MemberId, command.Comment, meetingCommentingConfiguration);

            await _meetingCommentRepository.AddAsync(meetingComment);

            return(meetingComment.Id.Value);
        }
        public async Task <Guid> Handle(AddReplyToMeetingCommentCommand command, CancellationToken cancellationToken)
        {
            var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(command.InReplyToCommentId));

            if (meetingComment == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "To create reply the comment must exist."
                });
            }

            var meeting = await _meetingRepository.GetByIdAsync(meetingComment.GetMeetingId());

            var meetingGroup = await _meetingGroupRepository.GetByIdAsync(meeting.GetMeetingGroupId());

            var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(meetingComment.GetMeetingId());

            var replyToComment = meetingComment.Reply(_memberContext.MemberId, command.Reply, meetingGroup, meetingCommentingConfiguration);
            await _meetingCommentRepository.AddAsync(replyToComment);

            return(replyToComment.Id.Value);
        }