Example #1
0
        public static MemberCardModel MemberCardModelFactory(string musername)
        {
            MembershipManager memMan = new MembershipManager();

            Member mUser = memMan.GetMemberByScreenName(musername);
            return MemberCardModelFactory(mUser);
        }
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                MembershipManager mmgr = new MembershipManager();
                try
                {
                    bool success = mmgr.LogMemberActivity(CurrentMember.MemberId,
                        context.ID.ToGuid(),
                        Constants.UserActivity_Values.Favorited,
                        Constants.UserActivity_Types.ContentRelated);

                    if (success)
                    {
                        lbSave.Attributes.Add("class", "icon-plus active");
                        lbSave.ServerClick += lbUnsave_Click;
                        lbSave.ServerClick -= lbSave_Click;
                    }
                }
                catch
                {

                }
            }
            else
            {
                string url = SignUpPageItem.GetSignUpPage().GetUrl();
                Response.Redirect(url);
            }
        }
        protected void uxSave_Click(object sender, EventArgs e)
        {
            uxMessage.Text = "";
            CurrentMember.AdvocacyAlerts = ux_advocacy_alerts.Checked;
            CurrentMember.ContentReminders = ux_content_reminders.Checked;
            CurrentMember.EventReminders =  ux_event_reminders.Checked;
            CurrentMember.NotificationsDigest = ux_notifications_digest.Checked;
            CurrentMember.ObservationLogReminders = ux_observation_log_reminders.Checked;
            CurrentMember.PrivateMessageAlerts = ux_private_message_alerts.Checked;
            CurrentMember.SupportPlanReminders = ux_support_plan_reminders.Checked;
            CurrentMember.allowNewsletter = ux_weekly_personalized_newsletter.Checked;

            CurrentMember.Subscribed_DailyDigest = ux_digest_email_daily.Checked;
            CurrentMember.Subscribed_WeeklyDigest = ux_digest_email_weekly.Checked; 

            
            MembershipManager mgr = new MembershipManager();
            try
            {
                mgr.UpdateMemberAlertPrefernces(CurrentMember);
                
            }
            catch(Exception ex)
            {
                uxMessage.Text = ex.Message ;
            }
            uxMessage.Text += DictionaryConstants.MyAccount_PreferencesSavedLabel;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //var un = string.Empty;

            if (!string.IsNullOrEmpty(Request.QueryString["un"]))
            {
                un = Request.QueryString["un"];
            }
            else
            {
                un = "*****@*****.**";
            }



            ////litRoles.Text = MembershipManager.isOpenToConnect(un).ToString();
            var membershipManager = new MembershipManager();
            //var sb = new StringBuilder();
            //var output = @"Method: {0}:{1}</br>";
            var member = membershipManager.GetMember(un);
            //var memberId = member.MemberId;

            //sb.Append(string.Format(output, "membershipManager.GetMemberByScreenName(un).Email", membershipManager.GetMemberByScreenName(un).Email));
            //sb.Append(string.Format(output, "membershipManager.GetMember(memberId).Email", membershipManager.GetMember(memberId).Email));
            //sb.Append(string.Format(output, "membershipManager.GetMember('[email protected]').Email", membershipManager.GetMember("[email protected]").Email));
            ////sb.Append(string.Format(output, "membershipManager.GetMember('[email protected]').Email", membershipManager.GetMembers().FirstOrDefault(x => x.Email == "[email protected]").Email));
            //sb.Append(string.Format(output, "membershipManager.GetMembers().FirstOrDefault(x => x.MemberId == memberId).Email", membershipManager.GetMembers().FirstOrDefault(x => x.MemberId == memberId).Email));
            //sb.Append(string.Format(output, "membershipManager.GetUser(memberId).Email", membershipManager.GetUser(memberId).Email));

            //litRoles.Text = sb.ToString();
            litEmail.Text = member.Email;
        }
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                MembershipManager mmgr = new MembershipManager();
                try
                {
                    bool success = mmgr.LogMemberActivity(CurrentMember.MemberId,
                        context.ID.ToGuid(),
                        Constants.UserActivity_Values.Favorited,
                        Constants.UserActivity_Types.ContentRelated);

                    if(success)
                    {
                        lbSave.CssClass = "icon icon-save active";
                        lbSave.Click += lbUnsave_Click;
                        lbSave.Click -= lbSave_Click;
                    }
                }
                catch
                {
                    
                }
            }
            else
            {
                this.ProfileRedirect(UnderstoodDotOrg.Common.Constants.UserPermission.RegisteredUser);
            }
        }
        private void VoteNeutral()
        {
            MembershipManager mmgr = new MembershipManager();
            try
            {
                //mmgr.LogMemberHelpfulVote

                bool success = mmgr.ClearHelpfulVote(CurrentMember.MemberId, context.ID.ToGuid(),
                    Constants.UserActivity_Values.FoundHelpful_True,
                    Constants.UserActivity_Types.FoundHelpfulVote);

                success = mmgr.ClearHelpfulVote(CurrentMember.MemberId, context.ID.ToGuid(),
                    Constants.UserActivity_Values.FoundHelpful_False,
                    Constants.UserActivity_Types.FoundHelpfulVote);

                if (success)
                {
                    btnNo.Attributes.Add("class", "helpful-no");
                    btnYes.Attributes.Add("class", "helpful-yes");
                    Response.Redirect(Request.RawUrl);
                }
            }
            catch
            {

            }
        }
        protected void btnGo_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtEmail.Text))
            {
                var membershipManager = new MembershipManager();
                var member = membershipManager.GetMember(un);

                var success = membershipManager.UpdateEmail(member, txtEmail.Text);

                Response.Write(success.ToString());
            }
        }
        void btnSearch_Click(object sender, EventArgs e)
        {
            MembershipManager mm = new MembershipManager();
            Child child = mm.GetChild(Guid.Parse(ddlChildren.SelectedValue));

            _parentInterests = child.Members.FirstOrDefault().Interests.Select(i => Sitecore.Context.Database.GetItem(i.Key))
                                    .Where(i => i != null)
                                    .Select(i => i.ID.ToGuid())
                                    .ToList();

            string childGrade = string.Empty;

            var grade = child.Grades.FirstOrDefault();
            if (grade != null)
            {
                GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                if (gli != null)
                {
                    // store value for data bound match
                    _childGuidId = grade.Key;

                    childGrade = gli.Name.Rendered;
                }
            }

            litChild.Text = String.Format("{0} ({1})", child.Nickname, childGrade);

            var issues = child.Issues.Select(i => Sitecore.Context.Database.GetItem(i.Key))
                                .Where(i => i != null)
                                .Select(i => new ChildIssueItem(i));
            if (issues.Any())
            {
                // store lookup values for data bound match
                _childIssues = issues.Select(i => i.ID.ToGuid()).ToList();

                rptIssues.DataSource = issues;
                rptIssues.DataBind();
            }

            DateTime specifiedDate = DateTime.Parse(txtDate.Text).Date;

            var articles = SearchHelper.GetArticles(child.Members.FirstOrDefault(), child, specifiedDate)
                                .Where(i => i.GetItem() != null);
            if (articles.Any())
            {
                rptArticles.DataSource = articles;
                rptArticles.DataBind();
            }
        }
        private void doLogin()
        {

            //blow out any existing member when someone tries to sign in
            try
            {
                //Reset session backed my groups from Whats Happening Now
                Session["_selectedGroups"] = null;
               
                //lets make sure to reset all user&member info before we start inflating it
                this.FlushCurrentMemberUser();

                var membershipManager = new MembershipManager();

                var currentMember = new Member();

                if (!string.IsNullOrEmpty(AccessToken))
                {
                    var client = new Facebook.FacebookClient(AccessToken);
                    dynamic me = client.Get("me", new { fields = "email" });

                    currentMember = membershipManager.GetMember(me.email);
                }
                else
                {
                    currentMember = membershipManager.AuthenticateUser(uxEmailAddress.Text, uxPassword.Text);
                }

                if (currentMember != null)
                {
                    this.CurrentMember = currentMember;
                    this.CurrentUser = membershipManager.GetUser(currentMember.MemberId, true);

                    this.ProfileRedirect(Constants.UserPermission.AgreedToTerms, null, true);

                    //Redirect used here for profile??
                    this.ReturnRedirect();

                    var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount);
                    // if you get this far, clear the redirect session URL 

                    Response.Redirect(Sitecore.Links.LinkManager.GetItemUrl(item));
                }
            }
            catch (Exception ex)
            {
                uxError.Text = ex.Message;
            }
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            Page.Validate("vlgEmailForm");

            if (Page.IsValid)
            {
                Item currentItem = Sitecore.Context.Item;

                InvokeEM24ContentSharedWithAFriendRequest message = new InvokeEM24ContentSharedWithAFriendRequest { RequestUrl = Request.Url };

                message.PMText = txtThoughts.Text.Trim();
                message.ToEmail = txtRecipientEmail.Text.Trim();
                message.UserContactFirstName = txtYourName.Text.Trim();
                message.RequestUrl = Request.Url;

                string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);

                if (currentItem != null)
                {
                    message.ReminderLink = domain + currentItem.GetUrl();
                }

                BaseReply reply = ExactTargetService.InvokeEM24ContentSharedWithAFriend(message);
                MembershipManager mmgr = new MembershipManager();

                if (IsUserLoggedIn)
                {
                    try
                    {
                        bool success = mmgr.LogMemberActivity(CurrentMember.MemberId,
                                currentItem.ID.ToGuid(),
                                Constants.UserActivity_Values.Shared,
                                Constants.UserActivity_Types.ContentRelated);
                    }
                    catch
                    {

                    }
                }

                pnlConfirmation.Visible = true;
                pnlForm.Visible = false;
            }
            else
            {
                validWarning.Visible = true;
            }
        }
        protected void btnThisHelped_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                var currentMember = this.CurrentMember;
                ActivityLog log = new ActivityLog();
                LinkButton btn = (LinkButton)(sender);
                string ids = btn.CommandArgument;
                string[] s = ids.Split('&');
                Guid? ContentId = s[0].AsNGuid();
                string contentTypeId = s[1];
                Guid MemberId = this.CurrentMember.MemberId;
                if (ContentId.HasValue && !(log.FoundItemHelpful(ContentId.Value, MemberId)))
                {
                    // instantiate MM
                    MembershipManager mgr = new MembershipManager();
                    // write to the DB
                    mgr.LogMemberHelpfulVote(MemberId, ContentId.Value, Constants.UserActivity_Values.FoundHelpful_True, Constants.UserActivity_Types.FoundHelpfulVote);
                    Response.Redirect(Request.RawUrl);
                    
                }
            }

            else
            {
                //this.ProfileRedirect(Constants.UserPermission.CommunityUser);
            }

            //var webClient = new WebClient();

            //// replace the "admin" and "Admin's API key" with your valid user and apikey!
            //var adminKey = String.Format("{0}:{1}", Settings.GetSetting(Constants.Settings.TelligentAdminApiKey), "admin");
            //var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));

            //webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
            //webClient.Headers.Add("Rest-Impersonate-User", this.CurrentMember.ScreenName.Trim());
            //var requestUrl = String.Format("{0}api.ashx/v2/likes.xml", Settings.GetSetting(Constants.Settings.TelligentConfig));

            //var values = new NameValueCollection();
            //values.Add("ContentId", contentId);
            //values.Add("ContentTypeId", contentTypeId);

            //var xml = Encoding.UTF8.GetString(webClient.UploadValues(requestUrl, values));

            //Console.WriteLine(xml);
        }
Example #12
0
        public static bool SendThinkingOfYou(string senderScreenName, string recipientScreenName)
        {
            try
            {
                //Grab text for thank you from dictionary
                string strThinkMsg = String.Format(DictionaryConstants.ThinkingOfYouMessage, senderScreenName);

                //Send private message
                string newConvID = TelligentService. TelligentService.CreateConversation(senderScreenName, DictionaryConstants.ThinkingOfYouLabel, strThinkMsg, recipientScreenName);

                if (!String.IsNullOrEmpty(newConvID))
                {
                    //Send email
                    MembershipManager mm = new MembershipManager();
                    Member recipient = mm.GetMemberByScreenName(recipientScreenName);

                    if (recipient != null)
                    {
                        //Send email
                        string myAccountLink = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount.ToString()));

                        BaseReply reply = Services.ExactTarget.ExactTargetService.InvokeEM21PrivateMessage(
                                                           new InvokeEM21PrivateMessageRequest
                                                           {
                                                               PreferredLanguage = recipient.PreferredLanguage,
                                                               ///TODO: change url to profile setting link
                                                               ContactSettingsLink = MembershipHelper.GetPublicProfileUrl(senderScreenName),
                                                               ///TODO: change URL to message centre link
                                                               MsgCenterLink = myAccountLink,
                                                               PMText = strThinkMsg,
                                                               ReportInappropriateLink = "*****@*****.**",
                                                               ToEmail = recipient.Email
                                                           });
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Error.LogError("Error sending thinking of you\n" + ex.Message);
            }

            return false;
        }
        protected void rptComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Comment comment = (Comment)e.Item.DataItem;
                Panel pnlAuthor = (Panel)e.FindControlAs<Panel>("pnlAuthor");
                Panel pnlComment = (Panel)e.FindControlAs<Panel>("pnlComment");

                HyperLink hlTitle = e.FindControlAs<HyperLink>("hlTitle");
                ContentPageItem item = Sitecore.Context.Database.GetItem(comment.SitecoreId);
                if (item != null)
                {
                    hlTitle.NavigateUrl = item.GetUrl();
                    hlTitle.Text = item.PageTitle.Rendered;
                }

                Literal litDate = e.FindControlAs<Literal>("litDate");
                litDate.Text = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(comment.CommentDate);

                Literal litComment = e.FindControlAs<Literal>("litComment");
                litComment.Text = UnderstoodDotOrg.Common.Helpers.TextHelper.TruncateText(
                    Sitecore.StringUtil.RemoveTags(HttpUtility.HtmlDecode(comment.Body)), commentCharLimit);

                Literal litLikeCount = e.FindControlAs<Literal>("litLikeCount");
                litLikeCount.Text = comment.Likes;

                if (e.Item.ItemIndex == 0 && DisplayAuthorInfo && ProfileMember != null)
                {
                    pnlAuthor.Visible = true;

                    Literal litScreenName = e.FindControlAs<Literal>("litScreenName");
                    litScreenName.Text = ProfileMember.ScreenName;

                    Literal litLastUpdated = e.FindControlAs<Literal>("litLastUpdated");
                    MembershipManager mm = new MembershipManager();
                    var user = mm.GetUser(ProfileMember.MemberId);
                    litLastUpdated.Text = user.LastActivityDate.ToString("hh:mmtt on MMM dd yyyy");
                }
                else
                {
                    pnlComment.CssClass += " offset-6";
                }
            }
        }
        public void BindData()
        {
            if (CurrentMember != null)
            {
                try
                {
                    MembershipManager mgr = new MembershipManager();
                    CurrentMember = mgr.QuizResults_FillMember(CurrentMember);
                    savedQuiz = CurrentMember.CompletedQuizes.Where(i => i.QuizID == Sitecore.Context.Item.ID.ToGuid()).FirstOrDefault<Quiz>();
                }
                catch
                {

                }
            }

            ObjChecklistArticle = new ChecklistArticlePageItem(Sitecore.Context.Item);
            if (ObjChecklistArticle != null)
            {
                PageUrl = ObjChecklistArticle.GetUrl();

                if (ObjChecklistArticle.ShowPromotionalControl.Checked == true)
                {
                    sbSidebarPromo.Visible = true;
                }
                else
                {
                    sbSidebarPromo.Visible = false;
                }
                // Create the checklist from base object
                if (ObjChecklistArticle.InnerItem.GetChildren() != null)
                {
                    //Get HeaderItems for Header Repeater
                    List<HeaderCheckboxItem> AllHeaders = ChecklistArticlePageItem.GetAllHeaderItem(ObjChecklistArticle);
                    if (AllHeaders != null)
                    {
                        rptHeaderChkbox.DataSource = AllHeaders;
                        rptHeaderChkbox.DataBind();

                    }
                }
            }
        }
        public static void RefreshAndSavePersonalizedContent(Guid childId)
        {
            DateTime now = DateTime.Now;

            Child child = null;
            MembershipManager mm = new MembershipManager();
            try
            {
                child = mm.GetChild(childId);
            }
            catch { }

            if (child.Members.Any())
            {
                foreach (Member m in child.Members)
                {
                    RefreshAndSavePersonalizedContent(m, child);
                }
            }
        }
        /// <summary>
        /// Log page view for subtopic filter nav
        /// </summary>
        private void LogViewForPopularity()
        {
            if (Sitecore.Context.PageMode.IsPreview)
            {
                return;
            }
            if (_currentItem.InheritsTemplate(DefaultArticlePageItem.TemplateId))
            {
                // Check for subtopic
                Item parent = _currentItem.Parent;
                if (parent != null 
                    && parent.InheritsTemplate(SubtopicLandingPageItem.TemplateId))
                {
                    // Setup user which page view will be logged against
                    var mm = new MembershipManager();
                    Guid viewer = Guid.Empty;
                    if (IsUserLoggedIn)
                    {
                        viewer = CurrentMember.MemberId;
                    }
                    else
                    {
                        // Look up shadow user
                        var shadowUser = mm.GetMemberByScreenName(Constants.UnauthenticatedMember_ScreeName);
                        if (shadowUser != null)
                        {
                            viewer = shadowUser.MemberId;
                        }
                    }

                    try
                    {
                        mm.LogSubtopicPageView(viewer, _currentItem.ID.ToGuid(), parent.ID.ToGuid());
                    }
                    catch (Exception ex)
                    {
                        Sitecore.Diagnostics.Log.Error("Error saving article view log", ex, this);
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ProfileUser != null)
            {
                // TODO: since we manage telligent users, we should be storing data on our member to avoid
                // unneeded api lookups
                var mm = new MembershipManager();
                _member = mm.GetMemberByScreenName(ProfileUser.Username);

                if (_member == null)
                {
                    return;
                }

                ProfileUrl = MembershipHelper.GetPublicProfileUrl(ProfileUser.Username);
                ProfileActivityUrl = MembershipHelper.GetPublicProfileActivityUrl(ProfileUser.Username);
            
                BindEvents();
                PopulateContent();
            }
        }
        public MemberCardModel(string username,Func<string,List<UserBadgeModel>> badgesPop=null)
        {
            MembershipManager memMan = new MembershipManager();

            Member mUser = memMan.GetMemberByScreenName(username);
            if (mUser != null)
            {
                initialize(mUser,badgesPop);
                    //this.AvatarUrl = Constants.Settings.AnonymousAvatar; ///TODO: find Avatar URL
                    //this.Children = mUser.Children.ConvertToChildCardModelList();
                    //this.UserLabel = "Blogger"; //TODO: find role                                                                                   
                    //this.UserLocation = Constants.Settings.DefaultLocation; //TODO: find location translate from zipcode
                    //this.UserName = mUser.ScreenName;
                    //this.Contactable = mUser.allowConnections;
                    //this.ProfileLink = mUser.GetMemberPublicProfile();
                    //if (badgesPop != null)
                    //    Badges = badgesPop(username);
                
            }
            
        }
        private void SetUpQuestionsTracker()
        {
            Quiz savedQuiz = null;
            if (CurrentMember != null)
            {
                try
                {
                    MembershipManager mgr = new MembershipManager();
                    CurrentMember = mgr.QuizResults_FillMember(CurrentMember);
                    savedQuiz = CurrentMember.CompletedQuizes.Where(i => i.QuizID == Sitecore.Context.Item.ID.ToGuid()).FirstOrDefault<Quiz>();
                }
                catch
                { 
                       
                }
            }

            Dictionary<string, QuestionAnswer>  answeredQuestions = new Dictionary<string, QuestionAnswer>();

            foreach (Item i in Pages)
            {
                foreach (Item j in i.Children)
                {
                    QuizItem potentialPreviousAnswer = null;

                    if (savedQuiz != null)
                        potentialPreviousAnswer = savedQuiz.MemberAnswers.Where(k => k.QuestionId == j.ID.ToGuid()).FirstOrDefault();

                    if (j.IsOfType(AssessmentTrueFalseItem.TemplateId) || j.IsOfType(AssessmentMultipleChoiceItem.TemplateId))
                    {
                        string answerValue = "";
                        if (potentialPreviousAnswer != null)
                            answerValue = potentialPreviousAnswer.AnswerValue;

                        answeredQuestions.Add(j.ID.ToString(), new QuestionAnswer(j, answerValue));
                    }
                }
            }

            Session["AnsweredQuestions"] = answeredQuestions;
        }
        protected void NextButton_Click(object sender, EventArgs e)
        {
            var child = new Child();

            if ((uxBoy1.Checked || uxGirl1.Checked) && uxSelectGrade1.SelectedValue != string.Empty)
            {
                child.Grades.Add(new Grade() { Key = Constants.GradesByValue[uxSelectGrade1.SelectedValue] });
                child.Gender = uxBoy1.Checked ? "boy" : "girl";
                //CurrentMember.Children.Add(child);
            }
            
            var issues = new List<Issue>();

            if (q1a1.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(0).Key, Value = Constants.Issues.ElementAt(0).Value }); }
            if (q1a2.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(1).Key, Value = Constants.Issues.ElementAt(1).Value }); }
            if (q1a3.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(2).Key, Value = Constants.Issues.ElementAt(2).Value }); }
            if (q1a4.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(3).Key, Value = Constants.Issues.ElementAt(3).Value }); }
            if (q1a5.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(4).Key, Value = Constants.Issues.ElementAt(4).Value }); }
            if (q1a6.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(5).Key, Value = Constants.Issues.ElementAt(5).Value }); }
            if (q1a7.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(6).Key, Value = Constants.Issues.ElementAt(6).Value }); }
            if (q1a8.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(7).Key, Value = Constants.Issues.ElementAt(7).Value }); }
            if (q1a9.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(8).Key, Value = Constants.Issues.ElementAt(8).Value }); }
            if (q1a10.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(9).Key, Value = Constants.Issues.ElementAt(9).Value }); }

            child.Issues = issues;
            child.Nickname = ScreenNameTextBox.Text;
            // handle redirects
            if (!q2a1.Checked) // Has (child) been formally evauluated for ...
            {
                //BG: Set alternative child evaulation status
                if (q2a2.Checked)//BG: Child has not been evaluated
                {
                    child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationNo);
                }
                else if (q2a3.Checked)//BG: Child evaluation is in progress
                {
                    child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationInProgress);
                }
            }
            else
            {
                child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationYes);

                if (uxIEPStatus.SelectedValue != string.Empty)
                {
                    child.IEPStatus = Guid.Parse(uxIEPStatus.SelectedValue);
                }

                if (ux504Status.SelectedValue != string.Empty)
                {
                    child.Section504Status = Guid.Parse(ux504Status.SelectedValue);
                }

                foreach (var item in uxLeftList.Items)
                {
                    var check = item.FindControl("diagnosis") as CheckBox;
                    if (check != null && check.Checked)
                    {
                        child.Diagnoses.Add(new Domain.Membership.Diagnosis() { Key = Guid.Parse(check.Attributes["guid"]) });
                    }
                }

                foreach (var item in uxRightList.Items)
                {
                    var check = item.FindControl("diagnosis") as CheckBox;
                    if (check != null && check.Checked)
                    {
                        child.Diagnoses.Add(new Domain.Membership.Diagnosis() { Key = Guid.Parse(check.Attributes["guid"]) });
                    }
                }
            }

            CurrentMember.Children.Add(child);
            
            var membershipManager = new MembershipManager();

            membershipManager.UpdateMember(CurrentMember);

            Response.Redirect(MyProfileItem.GetMyProfilePage().InnerItem.GetUrl());
        }
        private void SaveQuiz()
        {
            Guid thisGuid = Sitecore.Context.Item.ID.ToGuid();
            Quiz quiz = new Quiz();
            quiz.QuizID = thisGuid;
            Dictionary<string, QuestionAnswer> AnswerTracker = (Dictionary<string, QuestionAnswer>)Session["AnsweredQuestions"];

            foreach (KeyValuePair<string, QuestionAnswer> question in AnswerTracker)
            {
                quiz.MemberAnswers.Add(new QuizItem(new Guid(question.Key), question.Value.Answer));
            }

            try
            {
                MembershipManager mgr = new MembershipManager();
                mgr.QuizResults_SaveToDb(CurrentMember.MemberId, quiz);
            }
            catch
            { 
            
            }
        }
        void btnSubmit_Click(object sender, EventArgs e)
        {
            pnlResults.Update();

            MembershipManager mm = new MembershipManager();
            if (!string.IsNullOrEmpty(txtEmail.Text))
            {
                var member = mm.GetMember(txtEmail.Text);
                if (member != null)
                {
                    bool hasChildren = member.Children.Any();
                    pnlChildren.Visible = hasChildren;

                    if (hasChildren)
                    {
                        ddlChildren.DataSource = member.Children;
                        ddlChildren.DataTextField = "Nickname";
                        ddlChildren.DataValueField = "ChildId";
                        ddlChildren.DataBind();
                    }

                    if (member.Interests.Any())
                    {
                        rptInterests.DataSource = member.Interests;
                        rptInterests.DataBind();
                    }
                }
            }
        }
        protected void btnDidntHelp_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                var currentMember = this.CurrentMember;
                ActivityLog log = new ActivityLog();
                LinkButton btn = (LinkButton)(sender);
                string ids = btn.CommandArgument;
                string[] s = ids.Split('&');
                Guid? ContentId = s[0].AsNGuid();
                string contentTypeId = s[1];
                Guid MemberId = this.CurrentMember.MemberId;
                if (ContentId.HasValue && !(log.FoundItemNotHelpful(ContentId.Value, MemberId)))
                {
                    // instantiate MM
                    MembershipManager mgr = new MembershipManager();
                    // write to the DB
                    mgr.LogMemberHelpfulVote(MemberId, ContentId.Value, Constants.UserActivity_Values.FoundHelpful_False, Constants.UserActivity_Types.FoundHelpfulVote);
                    Response.Redirect(Request.RawUrl);
                }
                //ActivityLog log = new ActivityLog();
                //LinkButton btn = (LinkButton)(sender);
                //string ids = btn.CommandArgument;
                //string[] s = ids.Split('&');
                //Guid ContentId = new Guid(s[0]);
                //string contentTypeId = s[1];
                //Guid MemberId = this.CurrentMember.MemberId;


                //if ((log.FoundItemHelpful(ContentId, MemberId)))
                //{
                //    // instantiate MM
                //    MembershipManager mgr = new MembershipManager();
                //    // write to the DB
                //    mgr.LogMemberHelpfulVote(MemberId, ContentId, Constants.UserActivity_Values.FoundHelpful_False, Constants.UserActivity_Types.FoundHelpfulVote);
                //    Response.Redirect(Request.RawUrl);
                //}
            }
            else
            {
                //this.ProfileRedirect(Constants.UserPermission.CommunityUser);
            }

            //var like = new LikeModel();
            //if (!string.IsNullOrEmpty(username))
            //{
            //    like = CommunityHelper.GetLike(this.CurrentMember.ScreenName.Trim(), contentId, contentTypeId);
            //}
            //using (var webClient = new WebClient())
            //{
            //    try
            //    {
            //        // replace the "admin" and "Admin's API key" with your valid user and apikey!
            //        var adminKey = String.Format("{0}:{1}", Settings.GetSetting(Constants.Settings.TelligentAdminApiKey), "admin");
            //        var adminKeyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(adminKey));

            //        webClient.Headers.Add("Rest-User-Token", adminKeyBase64);
            //        webClient.Headers.Add("Rest-Method", "DELETE");

            //        var requestUrl = String.Format("{0}api.ashx/v2/likes.xml", Settings.GetSetting(Constants.Settings.TelligentConfig));

            //        var values = new NameValueCollection();
            //        values.Add("ContentUrl", like.ContentUrl);

            //        var xml = Encoding.UTF8.GetString(webClient.UploadValues(requestUrl, values));

            //        Console.WriteLine(xml);
            //    }
            //    catch { } //TODO: Add logging
            //}
        }
		protected void btnSaveAnswers_Click(object sender, EventArgs e)
		{
            if (IsUserLoggedIn)
            {
                try
                {

                    string JSON = hfKeyValuePairs.Value;
                    Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(JSON);

                    Checklist cl = new Checklist();
                    cl.MemberId = CurrentMember.MemberId;
                    cl.ChecklistID = Sitecore.Context.Item.ID.ToGuid();

                    if (values != null)
                    {
                        foreach (KeyValuePair<string, string> entry in values)
                        {
                            ChecklistItem clItem = new ChecklistItem();

                            clItem.QuestionId = new Guid(entry.Key);
                            clItem.Checked = Convert.ToBoolean(entry.Value);

                            cl.MemberAnswers.Add(clItem);
                        }
                        MembershipManager mgr = new MembershipManager();
                        mgr.ChecklistResults_SaveToDb(cl.MemberId, cl);

                        btnSaveAnswers.Attributes.Add("class", "aspNetDisabled submit button");
                        btnSaveAnswers.Attributes.Add("disabled", "disabled");
                        confirmationText.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    Sitecore.Diagnostics.Log.Error("\n\nAn error occurred while attempting to save checklist answers", ex, this);
                    errorText.Visible = true;  
                }
            }
            else
            {
                Response.Redirect(SignUpPageItem.GetSignUpPage().GetUrl());
            }

            BindData();
		}	
        protected void btnSendNewMessage_Click(object sender, EventArgs e)
        {
            string usernames = String.Join(",", chklUsernames.Items.Cast<ListItem>()
                .Where(li => li.Selected)
                .Select(li => li.Value).ToArray());
            string newConvID = TelligentService.CreateConversation(ScreenName, txtSubject.Text, CKEditorControl1.Text, usernames);
           
            if (!String.IsNullOrEmpty(newConvID))
            {
                try
                {
                    BindConversations(true);
                    rptMessages.DataSource = new List<Message>();
                    rptMessages.DataBind();

                    //Send ExactTarget Email
                    MembershipManager memMan = new MembershipManager();
                    string[] users = usernames.Split(',');
                    foreach (string username in users)
                    {
                        string memberEmail = TelligentService.GetMemberEmail(username);
                        string myAccountLink = LinkManager.GetItemUrl(Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount.ToString()));

                        BaseReply reply = ExactTargetService.InvokeEM21PrivateMessage(
                                                           new InvokeEM21PrivateMessageRequest
                                                           {
															   PreferredLanguage = CurrentMember.PreferredLanguage,
                                                               ///TODO: change url to profile setting link
                                                               ContactSettingsLink = MembershipHelper.GetPublicProfileUrl(username),
                                                               ///TODO: change URL to message centre link
                                                               MsgCenterLink = myAccountLink,
                                                               PMText = CKEditorControl1.Text,
                                                               ReportInappropriateLink = "*****@*****.**",
                                                               ToEmail = memberEmail,
                                                               RequestUrl = Request.Url
                                                           });

                    }

                }catch(Exception ex)
                {
                    Sitecore.Diagnostics.Error.LogError("SendNewMessage Error:\n" + ex.Message);
                }


                Response.Redirect(Request.Url.AbsolutePath);
            }
        }
        private bool UpdatePassword()
        {
            var ret = false;

            var membershipManager = new MembershipManager();

            ret = membershipManager.UpdatePassword(this.CurrentMember, txtOldPassword.Text, txtNewPassword.Text);

            return ret;
        }
        private bool UpdateEmail()
        {
            var ret = false;

            //email is not empty, passes regex
            var membershipManager = new MembershipManager();

            ret = membershipManager.UpdateEmail(this.CurrentMember, txtEmail.Text);

            return ret;
        }
        private void Page_Load(object sender, EventArgs e)
        {
            if (this.CurrentMember == null && this.CurrentUser == null)
            {
                if (!string.IsNullOrEmpty(CurrentPage.SignInPage.Url))
                {
                    Response.Redirect(CurrentPage.SignInPage.Url);
                }
                else
                {
                    Response.Redirect("/");
                }
            }

            if (!IsPostBack)
            {
                //update member
                MembershipManager membershipManager = new MembershipManager();
                this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId, true);

                MyProfileItem context = (MyProfileItem)Sitecore.Context.Item;
                HyperLink myHL = (HyperLink)this.FindControl("uxAddChild");
                myHL.Text = context.AddChildText;

                SetLabels();
                SetRole();

                uxChildList.DataSource = this.CurrentMember.Children;
                uxChildList.DataBind();

                //disable new children if you already have 6 or more
                if (this.CurrentMember.Children.Count >= 6)
                {
                    uxAddChild.Visible = false;
                }

                SetInterests();

                uxEmailAddress.Text = txtEmail.Text = this.CurrentUser.UserName;


                SetJourney();

                uxPassword.Text = replacePassword("digitalpulp!");

                string phoneNumber = string.Empty;

                if (!string.IsNullOrEmpty(this.CurrentMember.MobilePhoneNumber))
                {
                    phoneNumber = this.CurrentMember.MobilePhoneNumber.Replace("-", string.Empty).Trim();

                    //if (phoneNumber.Length == 10 && !phoneNumber.Contains("-"))
                    //{
                    phoneNumber = phoneNumber.Insert(3, "-");
                    phoneNumber = phoneNumber.Insert(7, "-");
                    //}
                }
                else
                {
                    //10 points to Gryffindor if you know where this phone number comes from
                    txtPhoneNumber.Attributes["placeholder"] = "212-555-2368";
                }

                uxPhoneNumber.Text = phoneNumber;
                txtPhoneNumber.Text = phoneNumber;

                uxPrivacyLevel.Text = this.CurrentMember.allowConnections ? DictionaryConstants.OpenToConnect : DictionaryConstants.NotOpenToConnect;

                uxScreenname.Text = this.CurrentMember.ScreenName;

                uxZipcode.Text = this.CurrentMember.ZipCode.Trim();

                uxAddChild.Text = string.Format(uxAddChild.Text, ((ChildCount)this.CurrentMember.Children.Count).ToString());
                uxAddChild.NavigateUrl = MyProfileStepTwoItem.GetCompleteMyProfileStepTwo().GetUrl() + "?" + Constants.QueryStrings.Registration.Mode + "=" + Constants.QueryStrings.Registration.ModeAdd;

                if (Session["PostReloadScript"] != null)
                {
                    string reloadScript = Session["PostReloadScript"].ToString();

                    if (reloadScript != "")
                    {
                        ltlJS.Text = string.Format("<script type=\"text/javascript\">{0}</script>", reloadScript);
                        Session["PostReloadScript"] = null;
                    }
                }

                //top of edit interests
                hypEditCommunityAboutMe.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                //jump to edit community
                hypEditCommunity.NavigateUrl = hypCompleteYourProfile.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}#community", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                if (!string.IsNullOrEmpty(this.CurrentMember.ScreenName))
                {
                    hypViewAsVisitors.NavigateUrl = MembershipHelper.GetPublicProfileAsVisitorUrl(CurrentMember.ScreenName);
                    hypViewAsMembers.NavigateUrl = MembershipHelper.GetPublicProfileAsMemberUrl(CurrentMember.ScreenName);
                    hypViewAsFriends.NavigateUrl = MembershipHelper.GetPublicProfileUrl(CurrentMember.ScreenName);
                }
                else
                {
                    uxNoProfile.Visible = true;
                    uxPublicView.Visible = false;
                }
            }
        }
        protected void lbSaveEmailPassword_Click(object sender, EventArgs e)
        {
            var action = false;

            try
            {
                if (!string.IsNullOrEmpty(this.txtEmail.Text))
                {
                    if (Regex.IsMatch(this.txtEmail.Text, Constants.Validators.Email))
                    {
                        //matched regex
                        if (this.UpdateEmail())
                        {
                            action = true;
                            
                            var membershipManager = new MembershipManager();

                            this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                            this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId, true);
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //did not match regex and not empty
                        throw new Exception(DictionaryConstants.PasswordErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }

            try
            {

                if (!string.IsNullOrEmpty(this.txtOldPassword.Text) && !string.IsNullOrEmpty(this.txtNewPassword.Text) && !string.IsNullOrEmpty(this.txtConfirmNewPassword.Text))
                {
                    if (this.txtNewPassword.Text == this.txtConfirmNewPassword.Text 
                        && Regex.IsMatch(this.txtNewPassword.Text, Constants.Validators.Password) 
                        && Regex.IsMatch(this.txtOldPassword.Text, Constants.Validators.Password))
                    {
                        if (this.UpdatePassword())
                        {
                            action = true;
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //new passwords don't match
                        throw new Exception(DictionaryConstants.PasswordMatchError);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }


            if (action)
            {
                Response.Redirect(Request.RawUrl, true);
            }
        }
        protected void lbSave_PhoneNumber_Click(object sender, EventArgs e)
        {
            this.CurrentMember.MobilePhoneNumber = txtPhoneNumber.Text.Replace("-", string.Empty);

            var membershipmManager = new MembershipManager();
            membershipmManager.UpdateMember(this.CurrentMember);

            Response.Redirect(Request.Url.ToString());
        }