public static string zipCodeToState(this Member member)
        {
            string state = String.Empty;

            // XmlNode node = null;
            try
            {
                //using (WebClient webClient = new WebClient())
                //{
                //    if (!String.IsNullOrEmpty(member.ZipCode))
                //    {
                //        var requestUrl = "www.webservicex.net/uszip.asmx/GetInfoByZIP?USZip=" + member.ZipCode.Trim();
                //        var xml = webClient.DownloadString(requestUrl);
                //        var xmlDoc = new XmlDocument();
                //        xmlDoc.LoadXml(xml);
                //        node = xmlDoc.SelectSingleNode("NewDataSet/Table/State");
                //        if (node != null)
                //        {
                //            state = node.InnerText;
                //        }
                //    }
                //}
                state = GeoTargeting.GetStateByZip(member.ZipCode);
            }catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error("Error from Member Extension Method zipCodeToState:\n " + ex.Message, ex);
            }
            return(state);
        }
Esempio n. 2
0
        private void PopulateContent()
        {
            hlBackToHomepage.NavigateUrl = MainsectionItem.GetHomePageItem().GetUrl();

            // TODO: find member location?
            litLocation.Text = GeoTargeting.GetStateByZip(ProfileMember.ZipCode);

            // Avatar
            var user = TelligentService.GetUser(ScreenName);

            if (user != null)
            {
                imgAvatar.ImageUrl = user.AvatarUrl;
            }
            else
            {
                // TODO: fallback image?
                imgAvatar.Visible = false;
            }

            // Hide support from user viewing their own profile
            if (IsUserLoggedIn &&
                !string.IsNullOrEmpty(CurrentMember.ScreenName) &&
                CurrentMember.ScreenName == ScreenName)
            {
                pnlSupport.Visible = false;
            }
            else
            {
                pnlSupport.Visible = ProfileMember.allowConnections;
            }

            // Conditional content for logged in viewers or impersonating visitor
            if (!IsUserLoggedIn || IsImpersonatingVistor)
            {
                if (ProfileMember.allowConnections && ProfileMember.Children.Any())
                {
                    rptChildren.DataSource = ProfileMember.Children;
                    rptChildren.DataBind();
                }
            }
            else
            {
            }
        }