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 meetingComment = meeting.AddComment(_memberContext.MemberId, command.Comment); 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); }