Пример #1
0
        public Promise ApplyInvitation()
        {
            string   invitationToken = ResolveInvitationToken();
            Deferred deferred        = new Deferred();

            if (string.IsNullOrEmpty(invitationToken))
            {
                deferred.Reject();
                return(deferred.Promise());
            }
            InvitationSaveData invitationSaveData =
                ServiceLocator.Resolve <IStorageService>().ResolveData <InvitationSaveData>();

            ServiceLocator.Resolve <IServerService>().CallTokenFull <object>("ApplyInvitation", new ApplyInvitationData
            {
                InvitorToken    = invitationToken,
                InvitationToken = ServiceLocator.Resolve <IUserManagementService>().GetSystemId()
            }).Then(o =>
            {
                invitationSaveData.Applied         = true;
                invitationSaveData.InvitationToken = invitationToken;
                ServiceLocator.Resolve <IStorageService>().UpdateData(invitationSaveData);
                ServiceLocator.Resolve <IAnalyticsService>().StatInvitationApplied();
                deferred.Resolve();
            }, () =>
            {
                invitationSaveData.Applied         = true;
                invitationSaveData.InvitationToken = invitationToken;
                ServiceLocator.Resolve <IStorageService>().UpdateData(invitationSaveData);
                deferred.Reject();
            });
            return(deferred.Promise());
        }
Пример #2
0
        public string ResolveInvitationToken()
        {
            string             invitationToken    = ResolveNewInvitationToken();
            InvitationSaveData invitationSaveData =
                ServiceLocator.Resolve <IStorageService>().ResolveData <InvitationSaveData>();

            if (invitationSaveData != null && invitationSaveData.Applied)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(invitationToken) && invitationSaveData != null)
            {
                return(invitationSaveData.InvitationToken);
            }
            return(invitationToken);
        }
Пример #3
0
        private void Update()
        {
            string invitationToken = ResolveNewInvitationToken();

            if (!string.IsNullOrEmpty(invitationToken))
            {
                InvitationSaveData invitationSaveData =
                    ServiceLocator.Resolve <IStorageService>().ResolveData <InvitationSaveData>();
                if (invitationSaveData == null || !invitationSaveData.Applied)
                {
                    invitationSaveData = new InvitationSaveData {
                        InvitationToken = invitationToken, Applied = false
                    };
                    ServiceLocator.Resolve <IStorageService>().UpdateData(invitationSaveData);
                }
            }
        }