Exemplo n.º 1
0
    private void doFacebookConnect()
    {
        StateManager stateManager = StateManager.Instance;
        SessionValue objSessionvalue = (SessionValue)stateManager.Get("objSessionvalue", StateManager.State.Session);
        if (objSessionvalue == null)
        {
            messageText.Text = "Your Tribute session had expired. Please log in.";
            refreshPage.Text = Request.QueryString["source"].ToString().Equals("headerLogin")
                ? "false" : "true";
        }
        else
        {
            UserRegistration objUserReg = new UserRegistration();
            TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users();
            objUsers.UserId = objSessionvalue.UserId;
            objUsers.FacebookUid = _FacebookUid;
            objUserReg.Users = objUsers;

            UserInfoManager umgr = new UserInfoManager();
            umgr.UpdateFacebookAssociation(objUserReg);
            StringBuilder sbr = new StringBuilder();
            if (objUserReg.CustomError != null)
            {

                var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
                var me = (IDictionary<string, object>)fbwc.Get("me");
                string fbName = (string)me["first_name"] + " " + (string)me["last_name"];

                sbr.Append(string.Format("<div class=\"yt-Error\"><h3>Sorry, {0}.</h3>", fbName));
                sbr.Append(string.Format(
                    "The Facebook account named {0} is aleady used by some other Your Tribute Account.",
                    fbName));
                sbr.Append("Would you like to:");
                sbr.Append("<ul>");
                sbr.Append("<li><a href=\"#\" onclick=\"fb_logout(); return false;\">");
                sbr.Append("   <img id=\"fb_logout_image\" ");
                sbr.Append("src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\"");
                sbr.Append(" alt=\"Logout from Facebook and Your Tribute\"/></a> of both Your Tribute and Facebook Connect ");
                sbr.Append("and switch to the other account using your Facebook email address and password.</li>");
                sbr.Append("<li><a href=\"#\" onclick=\"fb_err_logout(); return false;\">");
                sbr.Append("<img id=\"fb_logout_image\" ");
                sbr.Append("src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\"");
                sbr.Append(" alt=\"Disconnect from Facebook\"/></a> of Facebook Connect and try again.</li>");
                sbr.Append("<li><a href=\"javascript:void(0);\" onclick=\"OpenContactUS();\">Contact us</a> to discuss the situation further if you are confused.</li>");
                sbr.Append("</div>");

                messageText.Text = sbr.ToString();
                refreshPage.Text = "false";
            }
            else
            {
                if(Request.QueryString["source"].ToString().Equals("headerLogin"))
                {
                  refreshPage.Text = "true";
                } else {
                    messageText.Text = "<div class=\"yt-Notice\">Facebook Connection was added to your account.</div>";
                    refreshPage.Text = "false";
                }
            }
        }
    }
 public void UpdateFacebookAssociationTest()
 {
     UserInfoManager target = new UserInfoManager(); // TODO: Initialize to an appropriate value
     UserRegistration _objUserRegistration = null; // TODO: Initialize to an appropriate value
     target.UpdateFacebookAssociation(_objUserRegistration);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }