Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //bind texts and placeholders
            lblChildNickname.Text = Model.Childnicknameplaceholder.Rendered;
            txtChildNickname.Attributes["placeholder"] = Server.HtmlDecode(Model.Childnicknameplaceholder.Text);
            btnSubmit.Text                 = Model.SeeMyRecommendationsText.Rendered;
            hypCompleteProfile.Text        = Model.CompleteMyFullProfileText.Rendered;
            hypCompleteProfile.NavigateUrl = MyProfileStepOneItem.GetCompleteMyProfileStepOne().GetUrl();

            //validators
            valGender.ErrorMessage = DictionaryConstants.TellGenderofChildText;
            Page.ClientScript.RegisterExpandoAttribute(valGender.ClientID, "groupName", uxBoy.GroupName);

            valNickname.ErrorMessage = DictionaryConstants.GiveChildNicknameText;
            valGrade.ErrorMessage    = DictionaryConstants.GiveChildGradeText;

            if (!IsPostBack)
            {
                //bind issue list
                rptIssues.DataSource = ChildIssueItem.GetIssues();
                rptIssues.DataBind();

                //bind grade list
                var grades = GradeLevelItem.GetGrades().Select(x => new ListItem(x.Name, x.ID.ToString()));
                ddlGrades.DataSource     = grades;
                ddlGrades.DataTextField  = "Text";
                ddlGrades.DataValueField = "Value";
                ddlGrades.DataBind();

                ddlGrades.Items.Insert(0, new ListItem()
                {
                    Text = Model.Gradedefaultselection.Rendered, Value = string.Empty, Selected = true
                });
            }
        }
        /// <summary>
        /// Search button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            // First check hidden field
            string selectedGrade = hfGradeChoice.Value;

            if (String.IsNullOrEmpty(selectedGrade))
            {
                selectedGrade = ddlGradeGroups.SelectedValue;
            }

            if (String.IsNullOrEmpty(selectedGrade))
            {
                return;
            }

            // TODO: verify if it's ok to clear out unauthenticated user
            Member member = new Member();

            Child child = new Child();

            // TODO: replace child name
            child.Nickname = "Your Child";

            child.ChildId = Guid.NewGuid();

            foreach (RepeaterItem ri in rptChildIssues.Items)
            {
                CheckBox    cbIssue = (CheckBox)ri.FindControl("cbIssue");
                HiddenField hfIssue = (HiddenField)ri.FindControl("hfIssue");
                if (cbIssue.Checked)
                {
                    ChildIssueItem cii = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(hfIssue.Value));
                    if (cii != null)
                    {
                        child.Issues.Add(new Issue
                        {
                            Key   = Guid.Parse(cii.ID.ToString()),
                            Value = cii.IssueName.Raw
                        });
                    }
                }
            }

            GradeLevelItem gradeItem = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(selectedGrade));

            if (gradeItem != null)
            {
                child.Grades.Add(new Grade
                {
                    Key   = Guid.Parse(selectedGrade),
                    Value = gradeItem.Name.Raw
                });
            }

            member.Children.Add(child);
            UnauthenticatedSessionMember = member;

            // TODO: return unauthenticated users to different results page
            Response.Redirect(FormHelper.GetRecommendationUrl());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // TODO: refactor - similar code

            // Validate challenge
            if (!String.IsNullOrEmpty(SelectedChallenge))
            {
                Item challenge = FindChildById(Constants.ChallengesContainer, SelectedChallenge);
                if (challenge == null)
                {
                    // TODO: display error
                    return;
                }

                _challenge = new ChildChallengeItem(challenge);
            }

            // Validate grade
            if (!String.IsNullOrEmpty(SelectedGrade))
            {
                Item grade = FindChildById(Constants.GradeContainer, SelectedGrade);
                if (grade == null)
                {
                    // TODO: display error
                    return;
                }

                _grade = new GradeLevelItem(grade);
            }

            BindEvents();
            BindContent();
            BindResults();
        }
Beispiel #4
0
        void rptChildren_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Child child = (Child)e.Item.DataItem;

                Literal litGrade     = (Literal)e.Item.FindControl("litGrade");
                Literal litChildInfo = (Literal)e.Item.FindControl("litChildInfo");

                string childPrefix = string.Empty;

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    if (gli != null)
                    {
                        litGrade.Text = gli.AbbreviatedGrade.Raw;
                        childPrefix   = String.Concat(gli.Name.Raw, ", ");
                    }
                }

                litChildInfo.Text = String.Concat(childPrefix, MembershipHelper.GetLocalizedGender(child.Gender));

                Repeater rptIssues = e.FindControlAs <Repeater>("rptIssues");
                if (child.Issues.Any())
                {
                    var issues = child.Issues.Select(x => (ChildIssueItem)Sitecore.Context.Database.GetItem(x.Key))
                                 .Where(x => x != null);

                    rptIssues.DataSource = issues;
                    rptIssues.DataBind();
                }
            }
        }
        protected void DoSetup()
        {
            //cast to ListItem so we can better map over fields for name/value
            var grades = GradeLevelItem.GetGrades().Select(x => new ListItem(x.Name, x.ID.ToString()));

            uxSelectGrade.DataSource     = grades;
            uxSelectGrade.DataTextField  = "Text";
            uxSelectGrade.DataValueField = "Value";
            uxSelectGrade.DataBind();

            uxSelectGrade.Items.Insert(0, new ListItem()
            {
                Text = context.SelectGradeText, Value = string.Empty, Selected = true
            });

            switch (status)
            {
            case Constants.QueryStrings.Registration.ModeEdit:
                this.SetupChildEdit();
                litGenderGradeQuestion.Text = string.Format(context.GenderQuestionAText, singleChild.Nickname, singleChild.Gender);
                uxGender.Visible            = false;

                break;

            case Constants.QueryStrings.Registration.ModeAdd:
                this.SetupChildAdd();
                litGenderGradeQuestion.Text = context.GenderQuestionBText;

                break;

            default:
                this.SetupCompleteMyProfile();

                break;
            }

            NextButton.Text = NextButtonText;

            uxIssues.DataSource = ChildIssueItem.GetIssues();
            uxIssues.DataBind();

            uxTroubleAreasTitle.Text = Model.TroubleAreasQuestionTitle.Rendered.Replace("$pronoun$", pronoun);
            uxEvaluatedTitle.Text    = Model.FormallyEvaluatedQuestionTitle.Rendered.Replace("$pronoun$", pronoun);



            //set validation
            valGender.ErrorMessage = DictionaryConstants.TellGenderofChildText;
            Page.ClientScript.RegisterExpandoAttribute(valGender.ClientID, "groupName", uxBoy.GroupName);

            valEvalStatus.ErrorMessage = DictionaryConstants.HasChildBeenEvaluatedText;
            Page.ClientScript.RegisterExpandoAttribute(valEvalStatus.ClientID, "groupName", q2a1.GroupName);

            valNickname.ErrorMessage = DictionaryConstants.GiveChildNicknameText;
            valGrade.ErrorMessage    = DictionaryConstants.GiveChildGradeText;
        }
        protected void rptGrades_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                GradeLevelItem gradeItem = e.Item.DataItem as GradeLevelItem;

                HtmlButton gradeBtn = e.FindControlAs <HtmlButton>("gradeBtn");
                gradeBtn.Attributes.Add("data-value", gradeItem.ID.ToShortID().ToString());
                gradeBtn.InnerText = gradeItem.Name.Raw;
            }
        }
Beispiel #7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string selectedGrade = ddlGrade.SelectedValue;

            if (String.IsNullOrEmpty(selectedGrade))
            {
                return;
            }

            // TODO: verify if it's ok to clear out unauthenticated user
            Member member = new Member();

            Child child = new Child();

            // TODO: replace child name
            child.Nickname = txtChildName.Text;

            child.ChildId = Guid.NewGuid();

            if (!string.IsNullOrEmpty(hfIssues.Value))
            {
                string[] IDs = hfIssues.Value.Split('|');

                foreach (string s in IDs)
                {
                    ChildIssueItem cii = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(s));
                    if (cii != null)
                    {
                        child.Issues.Add(new Issue
                        {
                            Key   = Guid.Parse(cii.ID.ToString()),
                            Value = cii.IssueName.Raw
                        });
                    }
                }
            }

            GradeLevelItem gradeItem = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(selectedGrade));

            if (gradeItem != null)
            {
                child.Grades.Add(new Grade
                {
                    Key   = Guid.Parse(selectedGrade),
                    Value = gradeItem.Name.Raw
                });
            }

            member.Children.Add(child);
            UnauthenticatedSessionMember = member;

            // TODO: return unauthenticated users to different results page
            // Response.Redirect(FormHelper.GetRecommendationUrl());
        }
Beispiel #8
0
        protected void rptArticleGrades_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                GradeLevelItem item = (GradeLevelItem)e.Item.DataItem;

                Literal litGrade = e.FindControlAs <Literal>("litGrade");

                litGrade.Text = (_childGuidId == item.ID.ToGuid())
                    ? HighlightMatch(item.Name.Rendered) : item.Name.Rendered;
            }
        }
Beispiel #9
0
        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();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NextButton.Text = NextButtonText;

            FlushRegisteringUser();
            this.registeringUser = new Member();

            var gradeList = new List <ListItem>();

            foreach (var grade in GradeLevelItem.GetGrades())
            {
                gradeList.Add(new ListItem()
                {
                    Text = grade.Name.Raw, Value = grade.ID.ToString()
                });
            }

            uxSelectGrade1.Items.AddRange(gradeList.ToArray());
            uxSelectGrade1.DataBind();
            uxSelectGrade1.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));

            uxSelectGrade2.Items.AddRange(gradeList.ToArray());
            uxSelectGrade2.DataBind();
            uxSelectGrade2.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));

            uxSelectGrade3.Items.AddRange(gradeList.ToArray());
            uxSelectGrade3.DataBind();
            uxSelectGrade3.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));

            uxSelectGrade4.Items.AddRange(gradeList.ToArray());
            uxSelectGrade4.DataBind();
            uxSelectGrade4.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));

            uxSelectGrade5.Items.AddRange(gradeList.ToArray());
            uxSelectGrade5.DataBind();
            uxSelectGrade5.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));

            uxSelectGrade6.Items.AddRange(gradeList.ToArray());
            uxSelectGrade6.DataBind();
            uxSelectGrade6.Items.Insert(0, new ListItem(DictionaryConstants.SelectGradeLabel, string.Empty));
        }
Beispiel #11
0
        protected void rptChildren_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Domain.Membership.Child child = (Domain.Membership.Child)e.Item.DataItem;

                Literal litGrade = e.FindControlAs <Literal>("litGrade");
                litGrade.Text = string.Empty;

                Literal litChild    = e.FindControlAs <Literal>("litChild");
                string  gradePrefix = string.Empty;

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    if (gli != null)
                    {
                        string abbreviation = gli.AbbreviatedGrade.Rendered;

                        gradePrefix = abbreviation + ", ";

                        litGrade.Text = abbreviation;
                    }
                }

                // TODO: localize gender
                string gender = MembershipHelper.GetLocalizedGender(child.Gender);

                litChild.Text = String.Concat(gradePrefix, gender);

                // Issues
                Repeater rptIssues = e.FindControlAs <Repeater>("rptIssues");
                if (child.Issues.Any())
                {
                    rptIssues.DataSource = child.Issues;
                    rptIssues.DataBind();
                }
            }
        }
Beispiel #12
0
        void lvChildren_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                Child child = (Child)e.Item.DataItem;

                Literal litChild = (Literal)e.Item.FindControl("litChild");

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    litChild.Text = String.Format("{0}, {1}", gli.Name.Rendered, MembershipHelper.GetLocalizedGender(child.Gender));
                }

                Repeater rptIssues = (Repeater)e.Item.FindControl("rptIssues");
                if (child.Issues.Any())
                {
                    rptIssues.DataSource = child.Issues;
                    rptIssues.DataBind();
                }
            }
        }
Beispiel #13
0
 public StudentSearchItem()
 {
     GradeLevel = new GradeLevelItem();			
 }
Beispiel #14
0
        protected void rptChildRelatedArticles_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                DefaultArticlePageItem item = (DefaultArticlePageItem)e.Item.DataItem;
                {
                    HyperLink hlArticleImage = e.FindControlAs <HyperLink>("hlArticleImage");
                    HyperLink hlArticleTitle = e.FindControlAs <HyperLink>("hlArticleTitle");

                    hlArticleImage.NavigateUrl = hlArticleTitle.NavigateUrl = item.InnerItem.GetUrl();

                    Image imgThumbnail = e.FindControlAs <Image>("imgThumbnail");
                    imgThumbnail.ImageUrl = item.GetArticleThumbnailUrl(150, 85);

                    // DEBUG - START
                    Literal litDebugTag = e.FindControlAs <Literal>("litDebugTag");

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("");
                    sb.AppendLine("Sitecore web db tagging:");
                    sb.AppendLine("Grades:");

                    foreach (var grade in item.ChildGrades.ListItems)
                    {
                        GradeLevelItem gli = grade;
                        sb.AppendLine(HttpUtility.HtmlDecode(gli.Name.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Issues:");

                    foreach (var issue in item.ChildIssues.ListItems)
                    {
                        ChildIssueItem cii = issue;
                        sb.AppendLine(HttpUtility.HtmlDecode(cii.IssueName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Child Diagnoses:");

                    foreach (var diagnosis in item.ChildDiagnoses.ListItems)
                    {
                        ChildDiagnosisItem cdi = diagnosis;
                        sb.AppendLine(HttpUtility.HtmlDecode(cdi.DiagnosisName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Interests:");

                    foreach (var interest in item.ApplicableInterests.ListItems)
                    {
                        ParentInterestItem pii = interest;
                        sb.AppendLine(HttpUtility.HtmlDecode(pii.InterestName.Raw));
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Evaluations:");

                    foreach (var itemEval in item.OtherApplicableEvaluations.ListItems)
                    {
                        sb.AppendLine(itemEval.Name);
                    }

                    sb.AppendLine("");

                    sb.AppendLine("Diagnosed:");

                    foreach (var diag in item.DiagnosedCondition.ListItems)
                    {
                        sb.AppendLine(diag.Name);
                    }

                    sb.AppendLine("");

                    bool excluded = item.OverrideType.ListItems
                                    .Where(x => x.ID == Sitecore.Data.ID.Parse(Constants.ArticleTags.ExcludeFromPersonalization))
                                    .FirstOrDefault() != null;

                    sb.AppendLine(String.Format("Exclude from Personalization: {0}", excluded.ToString().ToLower()));

                    bool mustRead = item.ImportanceLevel.ListItems
                                    .Where(x => x.ID == Sitecore.Data.ID.Parse(Constants.ArticleTags.MustRead))
                                    .FirstOrDefault() != null;

                    sb.AppendLine(String.Format("Must read: {0}", mustRead.ToString().ToLower()));

                    sb.AppendLine(String.Format("Timely: {0}", IsTimely(item.DateStart.DateTime, item.DateEnd.DateTime).ToString()));

                    sb.AppendLine("");



                    Article article = SearchHelper.GetArticle(item.ID);
                    if (article != null)
                    {
                        sb.AppendLine("Solr index:");
                        sb.AppendLine("Grades:");

                        foreach (var grade in article.ChildGrades)
                        {
                            GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Guid);
                            if (gli != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(gli.Name.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Issues:");

                        foreach (var issue in article.ChildIssues)
                        {
                            ChildIssueItem cii = Sitecore.Context.Database.GetItem(issue.Guid);
                            if (cii != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(cii.IssueName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Child Diagnoses:");

                        foreach (var diagnosis in article.ChildDiagnoses)
                        {
                            ChildDiagnosisItem cdi = Sitecore.Context.Database.GetItem(diagnosis.Guid);
                            if (cdi != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(cdi.DiagnosisName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Interests:");

                        foreach (var interest in article.ParentInterests)
                        {
                            ParentInterestItem pii = Sitecore.Context.Database.GetItem(interest.Guid);
                            if (pii != null)
                            {
                                sb.AppendLine(HttpUtility.HtmlDecode(pii.InterestName.Raw));
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Evaluations:");

                        foreach (var itemEval in article.ApplicableEvaluations)
                        {
                            Item i = Sitecore.Context.Database.GetItem(itemEval);
                            if (i != null)
                            {
                                sb.AppendLine(i.Name);
                            }
                        }

                        sb.AppendLine("");

                        sb.AppendLine("Diagnosed:");

                        foreach (var diag in article.DiagnosedConditions)
                        {
                            Item i = Sitecore.Context.Database.GetItem(diag);
                            if (i != null)
                            {
                                sb.AppendLine(i.Name);
                            }
                        }

                        sb.AppendLine("");

                        bool excludedTag = article.OverrideTypes.Contains(Sitecore.Data.ID.Parse(Constants.ArticleTags.ExcludeFromPersonalization));

                        sb.AppendLine(String.Format("Exclude from Personalization: {0}", excludedTag.ToString().ToLower()));

                        bool mustReadTag = article.ImportanceLevels.Contains(Sitecore.Data.ID.Parse(Constants.ArticleTags.MustRead));
                        sb.AppendLine(String.Format("Must read: {0}", mustReadTag.ToString().ToLower()));

                        sb.AppendLine(String.Format("Timely: {0}", IsTimely(article.TimelyStart, article.TimelyEnd)));
                    }

                    litDebugTag.Text = String.Format("<!--{0}-->", sb.ToString());
                    // DEBUG - END
                }
            }
        }
Beispiel #15
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (IsUserLoggedIn)
            {
                Page.Validate("vlgReviewInputs");

                if (Page.IsValid)
                {
                    CSMUserReview review = new CSMUserReview();

                    if (hfRating.Value != null)
                    {
                        review.Rating = Int32.Parse(hfRating.Value);
                    }

                    if (!string.IsNullOrEmpty(hfKeyValuePairs.Value))
                    {
                        string[] IDs = hfKeyValuePairs.Value.Split('|');

                        foreach (string s in IDs)
                        {
                            review.UserReviewIssues.Add(new MetadataItem(Sitecore.Context.Database.GetItem(new Guid(s))));
                        }
                    }

                    GradeLevelItem grade = Sitecore.Context.Database.GetItem(ddlGrades.SelectedValue);

                    if (grade != null)
                    {
                        review.GradeAppropriateness = grade.GradeNumber;
                        review.RatedGradeId         = grade.ID.ToGuid();
                    }

                    if (txbReviewTitle.Text != null)
                    {
                        review.ReviewTitle = Sitecore.StringUtil.RemoveTags(txbReviewTitle.Text);
                    }

                    if (txbWhatYouThink != null)
                    {
                        review.ReviewBody = Sitecore.StringUtil.RemoveTags(txbWhatYouThink.Text);
                    }

                    review.CSMItemId      = Model.ID.ToGuid();
                    review.MemberId       = CurrentMember.MemberId;
                    review.BlogPostId     = Model.BlogPostId;
                    review.BlogId         = Model.BlogId;
                    review.ContentId      = Model.ContentId;
                    review.UserScreenName = CurrentMember.ScreenName;
                    review.IThinkItIs     = ddlIThinkItIs.SelectedValue;

                    try
                    {
                        CSMUserReviewExtensions.InsertNewReview(review);

                        BindReviews();

                        Response.Redirect(Request.RawUrl + "#tabs2-parent-reviews");
                    }
                    catch
                    {
                        //something went wrong
                    }
                }
            }
            else
            {
                Page.Session[Constants.SessionPreviousUrl] = null;
                this.ProfileRedirect(UnderstoodDotOrg.Common.Constants.UserPermission.RegisteredUser);
            }
        }