public async Task <FriendDto> Create(Guid userId, Guid friendUserId) { if (Equals(userId, friendUserId)) { throw new Exception("Failed to create friend request, cannot invite yourself"); } if (await _repository.Exists(userId, friendUserId)) { throw new Exception("A friends connection or request already exists between these users"); } var friend = Friend.Create(userId, friendUserId); if (await _repository.Create(friend)) { friend = await _repository.GetSingle(friend.Id); var invitee = await _usersRepository.Get(userId); PublicFriendInvitationReceivedEvent(friendUserId, invitee.Name); return(friend?.ToDto()); } return(null); }