Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Comments = TelligentService.ReadComments(Model.BlogId, Model.BlogPostId);
            Reviews  = CSMUserReviewExtensions.GetReviews(Sitecore.Context.Item.ID.ToGuid());


            if (IsUserLoggedIn)
            {
                if (Reviews.Where(i => i.MemberId == CurrentMember.MemberId).Count() > 0)
                {
                    SubmittedReview = true;
                }
            }

            if (!IsPostBack)
            {
                BindDropDowns();
                BindReviews();
            }

            AssistiveToolsSkillFolderItem issuesFolder = MainsectionItem.GetGlobals().GetIssuesFolder();

            rptIssuesChecklist.DataSource = issuesFolder.InnerItem.Children.Select(i => (MetadataItem)i);
            rptIssuesChecklist.DataBind();

            litAverageRating.Text = GetRatingHTML(Int32.Parse(CSMUserReviewExtensions.GetAverageRating(Model.ID.ToGuid())));

            rfvGrades.ErrorMessage       = DictionaryConstants.ReviewSelectGradeErrorMessage;
            rfvIThinkItIs.ErrorMessage   = DictionaryConstants.ReviewIThinkItIsErrorMessaage;
            rfvWhatYouThink.ErrorMessage = DictionaryConstants.ReviewWhatYouThinkErrorMessage;
            rfvReviewTitle.ErrorMessage  = DictionaryConstants.ReviewGiveTitleErrorMessage;
        }
        protected void BindUserReviews()
        {
            // TODO: don't retrieve all reviews
            var reviews = CSMUserReviewExtensions.GetRecentReviews()
                          .Select(userReview =>
            {
                AssistiveToolsReviewPageItem item = (AssistiveToolsReviewPageItem)Sitecore.Context.Database.GetItem(userReview.CSMItemId);
                var url           = item.GetUrl();
                var grade         = Sitecore.Context.Database.GetItemAs <GradeLevelItem>(userReview.RatedGradeId);
                var comment       = TelligentService.ReadComments(item.BlogId, item.BlogPostId).Where(i => new Guid(i.CommentId).ToString() == userReview.TelligentCommentId.ToString()).FirstOrDefault();
                var processedBody = comment != null && !string.IsNullOrEmpty(comment.Body) && comment.Body.Length > 100 ?
                                    ""
                                    .TakeWhile((c, i) => i < comment.Body.Length && (i < 100 || Char.IsLetter(c))) :
                                    comment.Body;
                var reviewBody = processedBody != null && processedBody.Any() ? new String(processedBody.ToArray()) : string.Empty;

                return(new
                {
                    Title = userReview.ReviewTitle,
                    ReviewText = "<p>" + Sitecore.StringUtil.RemoveTags(reviewBody) + "...<a href=\"" + url + "\">" + DictionaryConstants.ReadMoreLabel + "</a></p>",
                    RatingHtml = GetRatingHTML(userReview.Rating),
                    Url = url,
                    LinkText = (grade != null ? grade.Name.Raw + " & " : string.Empty) +
                               string.Join(" & ", userReview.UserReviewIssues.Select(i => i.ContentTitle.Raw))
                });
            });

            if (reviews.Count() > 0)
            {
                rptrWhatParentsAreSaying.DataSource = reviews;
                rptrWhatParentsAreSaying.DataBind();
            }
            else
            {
                divParentReviews.Visible = false;
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            #region Dictionary Constants
            lblAboutOurRatingSystem.Text = DictionaryConstants.AboutOurRatingSystemLabel;
            lblBestFragment.Text         = DictionaryConstants.BestFragment;
            lblContentIsAppropriate.Text = DictionaryConstants.ContentIsAppropriateLabel;
            lblDisappointing.Text        = DictionaryConstants.DisappointingLabel;
            lblDontBother.Text           = DictionaryConstants.DontBotherLabel;
            lblEngaging.Text             = DictionaryConstants.EngagingLabel;
            lblFairFragment.Text         = DictionaryConstants.Fairfragment;
            lblGoodFragment.Text         = DictionaryConstants.Goodfragment;
            lblGrade.Text                  = DictionaryConstants.GradeLabel;
            lblGrade1.Text                 = DictionaryConstants.GradeLabel;
            lblJustFine.Text               = DictionaryConstants.GradeLabel;
            lblKnowYourChild.Text          = DictionaryConstants.KnowYourChildLabel;
            lblLearningFragment.Text       = DictionaryConstants.Learningfragment;
            lblLearningFragment1.Text      = DictionaryConstants.Learningfragment;
            lblMoreInformation.Text        = DictionaryConstants.MoreInformationLabel;
            lblMoreInformation1.Text       = DictionaryConstants.MoreInformationLabel;
            lblMoreInformation2.Text       = DictionaryConstants.MoreInformationLabel;
            lblNotAgeAppropriate.Text      = DictionaryConstants.NotAgeAppropriateLabel;
            lblNotAppropriate.Text         = DictionaryConstants.NotAppropriateLabel;
            lblNotForKidsFragment.Text     = DictionaryConstants.NotAppropriateLabel;
            lblNotForLearningFragment.Text = DictionaryConstants.NotForLearningfragment;
            lblNotRecommended.Text         = DictionaryConstants.NotRecommendedLabel;
            lblOffFragment.Text            = DictionaryConstants.OffFragment;
            lblOnFragment.Text             = DictionaryConstants.OnRatingLabel;
            lblPauseFragment.Text          = DictionaryConstants.Pausefragment;
            lblPrettyEngaging.Text         = DictionaryConstants.PrettyEngagingLabel;
            lblQuality.Text                = DictionaryConstants.QualityLabel;
            lblQuality1.Text               = DictionaryConstants.QualityLabel;
            lblQualityRating.Text          = DictionaryConstants.QualityRatingLabel;
            lblReallyEngaging.Text         = DictionaryConstants.ReallyEngagingLabel;
            lblReallyGood.Text             = DictionaryConstants.ReallyGoodLabel;
            lblSearch.Text                 = DictionaryConstants.SearchLabel;
            lblSeeRating.Text              = DictionaryConstants.SeeRatingLabel;
            lblSomewhatEngaging.Text       = DictionaryConstants.SomewhatEngagingLabel;
            lblTheBest.Text                = DictionaryConstants.TheBestLabel;
            lblVeryGoodFragment.Text       = DictionaryConstants.VeryGoodfragment;
            #endregion

            var screenshots = Model.Screenshots.ListItems
                              .Where(i => i != null && i.Paths.IsMediaItem)
                              .Select(i => (MediaItem)i);

            rptrScreenshots.DataSource = screenshots
                                         .Select(mi => new
            {
                Alt = mi.Alt,
                Url = mi.GetImageUrl()
            }).ToList();
            rptrScreenshots.DataBind();

            var appropriateGrades = Enumerable.Range(1, 12)
                                    .Select(i => new
            {
                Grade = i,
                Color = i <= Model.OffGrade ? "red" : i < Model.OnGrade ? "yellow" : "green"
            });

            rptrAppropriateGrades.DataSource = appropriateGrades;
            rptrAppropriateGrades.DataBind();

            rptrAppropriateGrades2.DataSource = appropriateGrades;
            rptrAppropriateGrades2.DataBind();

            var subjects = Model.Subjects.ListItems
                           .Where(i => i != null && i.IsOfType(AssistiveToolsSubjectItem.TemplateId))
                           .Select(i => (AssistiveToolsSubjectItem)i).ToList();

            rptrSubjects.DataSource = subjects;
            rptrSubjects.DataBind();

            litNumReviews.Text = CSMUserReviewExtensions.GetReviews(Model.ID.ToGuid()).Count().ToString();

            MetadataItem type = (MetadataItem)Model.Type.ListItems.FirstOrDefault();

            if (type != null)
            {
                litType.Text = type.ContentTitle.Raw;
            }

            litDate.Text = Model.PublishDate.DateTime.Year.ToString();
        }