Exemplo n.º 1
0
    private IEnumerator InviteFriend(string userID, string friendID, Result <bool> result)
    {
        Result <StorageAccountInfo> r = new Result <StorageAccountInfo>(this);

        yield return(StartCoroutine(storage.GetAccountByUserID(userID, r)));

        var user = r.Value;

        yield return(StartCoroutine(storage.GetAccountByUserID(friendID, r)));

        var friend = r.Value;

        if (user != null && friend != null)
        {
            Result <StorageInvitationsCollection> res = new Result <StorageInvitationsCollection>(this);
            yield return(StartCoroutine(storage.GetInvitations(friend.userID, res)));

            var invitaitonList = res.Value;
            var invitation     = new InvitationInfo();
            invitation.invitationID = System.Guid.NewGuid().ToString();
            invitation.inviterID    = userID;
            invitation.InviteeID    = friendID;
            invitation.groupName    = "";
            invitaitonList.invites.Add(invitation);
            yield return(StartCoroutine(storage.SetInvitations(friend.userID, invitaitonList, result)));

            yield break;
        }
        result.SetValue(false);
    }