private static void HandleFriendshipInvitationAdded(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractAddFriendshipInvitationNotificationEventArgs e)
    {
        AddFriendshipInvitationNotification notification = e.Notification;
        FriendshipInvitation invitation = notification.Invitation;
        User friend = notification.Friend;

        userDatabase.PersistUser(null, null, invitation.FriendDisplayName, friend.FirstName, friend.Status);
        FriendInvitationDocument friendInvitationDocument = new FriendInvitationDocument();

        friendInvitationDocument.FriendInvitationId = invitation.FriendshipInvitationId.Value;
        friendInvitationDocument.IsInviter          = invitation.IsInviter.Value;
        friendInvitationDocument.IsTrusted          = invitation.IsTrusted.Value;
        friendInvitationDocument.DisplayName        = invitation.FriendDisplayName;
        FriendInvitationDocument doc = friendInvitationDocument;

        userDatabase.InsertOrUpdateFriendInvitation(doc);
        localUser.AddFriendshipInvitation(invitation, friend);
    }
    private static void HandleFriendshipAdded(IUserDatabase userDatabase, IInternalLocalUser localUser, AbstractAddFriendshipNotificationEventArgs e)
    {
        AddFriendshipNotification notification = e.Notification;
        User friend = notification.Friend;

        userDatabase.PersistUser(friend.UserId, friend.HashedUserId, friend.DisplayName, friend.FirstName, friend.Status);
        FriendDocument friendDocument = new FriendDocument();

        friendDocument.Swid      = friend.UserId;
        friendDocument.IsTrusted = notification.IsTrusted.Value;
        friendDocument.Nickname  = null;
        FriendDocument doc = friendDocument;

        userDatabase.InsertFriend(doc);
        long value = e.Notification.FriendshipInvitationId.Value;

        userDatabase.DeleteFriendInvitation(value);
        localUser.AddFriend(friend, notification.IsTrusted.Value, value);
    }