Example #1
0
        private async Task PopulateMSAccountData(MSAccountPageModel model, AccountDataContent content)
        {
            string              errorText = null;
            LiveConnectClient   client    = new LiveConnectClient(this.MSAuthClient.Session);
            LiveOperationResult meResult  = await QueryUserData(client, "me");

            if (meResult != null)
            {
                dynamic meInfo = meResult.Result;
                model.Name         = meInfo.name;
                model.ProfileImage = await GetProfileImageData(client);
            }
            else
            {
                errorText = "There was an error while retrieving the user's information. Please try again later.";
            }

            if (errorText == null &&
                (content & AccountDataContent.Contacts) == AccountDataContent.Contacts)
            {
                LiveOperationResult contactsResult = await QueryUserData(client, "me/contacts");

                if (contactsResult != null)
                {
                    dynamic contacts = contactsResult.Result;
                    model.Contacts = contacts.data;
                }
                else
                {
                    errorText = "There was an error while retrieving the user's contacts data. Please try again later.";
                }
            }

            model.Error = errorText;
        }
Example #2
0
        private async Task <ActionResult> BuildMSAccountPageView(string[] scopes, AccountDataContent content)
        {
            MSAccountStatus accountStatus = this.MSAccountStatus;

            MSAccountPageModel model = new MSAccountPageModel()
            {
                Status          = accountStatus,
                AjaxClientURL   = this.AjaxClientPath,
                ShowContactsURL = this.ShowContactsPath
            };

            if (accountStatus == MSAccountStatus.Connected)
            {
                await this.PopulateMSAccountData(model, content);
            }
            else
            {
                Dictionary <string, string> options = new Dictionary <string, string>();
                options["state"] = "connect";
                model.LoginUrl   = this.MSAuthClient.GetLoginUrl(scopes, this.SiteRootPath + "account/connectcallback", options);
            }

            return(View("MSAccountPage", model));
        }