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." }); } meetingComment.Edit(_memberContext.MemberId, command.EditedComment); return(Unit.Value); }
public async Task <Unit> Handle(RemoveMeetingCommentCommand command, CancellationToken cancellationToken) { var meetingComment = await _meetingCommentRepository.GetByIdAsync(command.MeetingCommentId); if (meetingComment == null) { throw new InvalidCommandException(new List <string> { "Meeting comment for removing must exist." }); } var meeting = await _meetingRepository.GetByIdAsync(meetingComment.GetMeetingId()); var meetingGroup = await _meetingGroupRepository.GetByIdAsync(meeting.GetMeetingGroupId()); meetingComment.Remove(_memberContext.MemberId, meetingGroup, command.Reason); return(Unit.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); }
public async Task <Unit> Handle(AddMeetingCommentLikeCommand request, CancellationToken cancellationToken) { var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(request.MeetingCommentId)); if (meetingComment == null) { throw new InvalidCommandException(new List <string> { "To add like the comment must exist." }); } var connection = _sqlConnectionFactory.GetOpenConnection(); var likerMeetingGroupMemberData = await MembersQueryHelper.GetMeetingGroupMember(_memberContext.MemberId, meetingComment.GetMeetingId(), connection); var meetingMemeberCommentLikesCount = await _meetingMemberCommentLikesRepository.CountMemberCommentLikesAsync( _memberContext.MemberId, new MeetingCommentId(request.MeetingCommentId)); var like = meetingComment.Like(_memberContext.MemberId, likerMeetingGroupMemberData, meetingMemeberCommentLikesCount); await _meetingMemberCommentLikesRepository.AddAsync(like); return(Unit.Value); }