public async Task HandleAsync(FollowUser command) { if (command.UserId == command.FolloweeId) { throw new FollowerAndFolloweeIdAreTheSameException(command.UserId); } var follower = await _followerRepository.GetAsync(command.UserId, command.FolloweeId); if (follower is {})
public async Task HandleAsync(UnfollowUser command) { if (command.UserId == command.FolloweeId) { throw new FollowerAndFolloweeIdAreTheSameException(command.UserId); } var follower = await _followerRepository.GetAsync(command.UserId, command.FolloweeId); if (follower is null) { return; } await _followerRepository.DeleteAsync(follower.Id); await _messageBroker.PublishAsync(new UserUnfollowed(command.UserId, command.FolloweeId)); }