protected void Page_Load(object sender, EventArgs e)
        {
            List <INotification> notifs      = new List <INotification>();
            List <Conversation>  checkConvos = new List <Conversation>();

            if (IsUserLoggedIn)
            {
                if (!String.IsNullOrEmpty(CurrentMember.ScreenName))
                {
                    if (Notifications != null)
                    {
                        notifs = Notifications;
                    }
                    else
                    {
                        notifs = TelligentService.GetNotifications(CurrentMember.ScreenName);
                        if (notifs != null)
                        {
                            Notifications = notifs;
                        }
                        else
                        {
                            Notifications = new List <INotification>();
                        }
                    }


                    if (Conversations != null)
                    {
                        checkConvos = Conversations;
                    }
                    else
                    {
                        checkConvos = TelligentService.GetConversations(CurrentMember.ScreenName, Constants.TelligentConversationStatus.Unread);
                        if (checkConvos != null)
                        {
                            Conversations = checkConvos;
                        }
                        else
                        {
                            checkConvos   = new List <Conversation>();
                            Conversations = checkConvos;
                        }
                    }
                }
            }



            litNotifsCount.Text         = notifs != null && notifs.Count() > 0?notifs.Count().ToString():"0";
            litwhatsHappeningLabel.Text = DictionaryConstants.WhatsHappeningLabel;
            litPrivateMsgsLabel.Text    = DictionaryConstants.PrivateMessagesLabel;
            litEmailPrefLabel.Text      = DictionaryConstants.EmailPreferencesLabel;
            litPMs.Text = checkConvos.Count().ToString();
            if (!IsPostBack)
            {
                if (Sitecore.Context.Item.TemplateID.ToString() == EmailandAlertPreferencesPageItem.TemplateId)
                {
                    liEmailPreferencesTab.Attributes["class"] += "active";
                }

                if (Sitecore.Context.Item.TemplateID.ToString() == PrivateMessageToolItem.TemplateId)
                {
                    liMessagesTab.Attributes["class"] += "active";
                }

                if (Sitecore.Context.Item.TemplateID.ToString() == MyNotificationsPageItem.TemplateId)
                {
                    liNotificationsTab.Attributes["class"] += "active";
                }

                // TODO: refactor
                hypWhatsHappening.NavigateUrl           = MainsectionItem.GetHomePageItem().GetMyAccountFolder().GetMyNotificationsPage().GetUrl();
                hypEmailAndAlertPreferences.NavigateUrl = MainsectionItem.GetHomePageItem().GetMyAccountFolder().GetMyNotificationsPage().GetEmailAndAlertPreferences().InnerItem.GetUrl();
                hypPrivateMessages.NavigateUrl          = MainsectionItem.GetHomePageItem().GetMyAccountFolder().GetMyNotificationsPage().GetPrivateMessageTool().InnerItem.GetUrl();
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            litNotificationsLabel.Text = DictionaryConstants.NotificationsButtonLabel;
            if (IsUserLoggedIn)
            {
                MyProfilePage = MyProfileItem.GetMyProfilePage();
                MyAccountPage = MyAccountItem.GetMyAccountPage();

                btnUpload.Text = MyAccountPage.AvatarUploadButtonText.Rendered;

                var accountPages = MyAccountPage.GetAccountPages();
                rptrAccountNav.DataSource = accountPages;
                rptrAccountNav.DataBind();

                hlSectionTitle.NavigateUrl = MainsectionItem.GetHomePageItem().GetUrl();
                frSectionTitle.Item        = MainsectionItem.GetHomePageItem();

                if (CurrentMember.ZipCode != null)
                {
                    if (!string.IsNullOrEmpty(CurrentMember.ScreenName))
                    {
                        litLocation.Text = Services.CommunityServices.GeoTargeting.GetStateByZip(CurrentMember.ZipCode);
                    }
                }

                if (!String.IsNullOrEmpty(CurrentMember.ScreenName))
                {
                    List <INotification> notifs      = new  List <INotification>();
                    List <Conversation>  checkConvos = new List <Conversation>();
                    if (Notifications == null)
                    {
                        notifs = TelligentService.GetNotifications(CurrentMember.ScreenName);
                        if (notifs != null && notifs.Count() > 0)
                        {
                            //spnCount.Visible = true;
                            //litNotifCount.Text = notifs.Count().ToString();
                            Notifications = notifs;
                        }
                        else
                        {
                            notifs        = new List <INotification>();
                            Notifications = notifs;
                        }
                    }
                    else
                    {
                        notifs = Notifications;
                    }

                    if (Conversations == null)
                    {
                        checkConvos = TelligentService.GetConversations(CurrentMember.ScreenName, Constants.TelligentConversationStatus.Unread);
                        if (checkConvos != null && checkConvos.Count() > 0)
                        {
                            Conversations = checkConvos;
                        }
                        else
                        {
                            checkConvos   = new List <Conversation>();
                            Conversations = checkConvos;
                        }
                    }
                    else
                    {
                        checkConvos = Conversations;
                    }
                    int totalNotifs = notifs.Count() + checkConvos.Count();
                    if (totalNotifs > 0)
                    {
                        spnCount.Visible   = true;
                        litNotifCount.Text = totalNotifs.ToString();
                    }
                    else
                    {
                        spnCount.Visible = false;
                    }
                }
            }
            else
            {
                Response.Redirect(MainsectionItem.GetHomePageItem().GetUrl());
            }

            if (CurrentMember != null && !string.IsNullOrEmpty(CurrentMember.ScreenName))
            {
                try
                {
                    User user = TelligentService.GetUser(this.CurrentMember.ScreenName);
                    if (user != null)
                    {
                        userAvatar.Src = user.AvatarUrl;
                    }
                }
                catch { }
            }

            //if (!IsPostBack)
            //{
            //    try
            //    {
            //        if (CurrentMember.ScreenName != null)
            //        {
            //            userAvatar.Src = TelligentService.GetUser(this.CurrentMember.ScreenName).AvatarUrl;
            //        }
            //    }
            //    catch { }
            //}
        }