Ejemplo n.º 1
0
        protected void GoButton_Click(object sender, EventArgs e)
        {
            List <int> reviewIds = GetSelectedReviewIds();

            if (reviewIds.Count > 0)
            {
                if (ReviewAction.SelectedValue == "Delete")
                {
                    foreach (int reviewId in reviewIds)
                    {
                        ProductReviewDataSource.Delete(reviewId);
                    }
                }
                else if ((ReviewAction.SelectedValue == "Approve") || (ReviewAction.SelectedValue == "Disapprove"))
                {
                    bool approved = (ReviewAction.SelectedValue == "Approve");
                    foreach (int reviewId in reviewIds)
                    {
                        ProductReview review = ProductReviewDataSource.Load(reviewId);
                        review.IsApproved = approved;
                        review.Save();
                    }
                }
                ReviewGrid.DataBind();
            }
            ReviewAction.SelectedIndex = 0;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _ProductReviewId = AlwaysConvert.ToInt(Request.QueryString["ReviewId"]);
            _ProductReview   = ProductReviewDataSource.Load(_ProductReviewId);

            if (_ProductReview != null)
            {
                _ProductId = _ProductReview.Product.Id;
            }
            else
            {
                _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            }
            _Product = ProductDataSource.Load(_ProductId);

            if (!Page.IsPostBack)
            {
                InitializeForm();
            }

            //INIT ReviewBody COUNTDOWN
            AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(ReviewBody, ReviewMessageCharCount);
            ReviewMessageCharCount.Text = ((int)(ReviewBody.MaxLength - ReviewBody.Text.Length)).ToString();

            if (AbleContext.Current.Store.Settings.ProductReviewTermsAndConditions != string.Empty)
            {
                ReviewTermsLink.Visible     = true;
                ReviewTermsLink.NavigateUrl = NavigationHelper.GetMobileStoreUrl(string.Format("~/ReviewTerms.aspx?ProductId={0}", _Product.Id));
            }
            else
            {
                ReviewTermsLink.Visible   = false;
                reviewInstruction.Visible = false;
            }
        }
        public void InitializeForm()
        {
            StoreSettingsManager settings = AbleContext.Current.Store.Settings;

            if (settings.ProductReviewEnabled != UserAuthFilter.None)
            {
                if ((settings.ProductReviewEnabled == UserAuthFilter.Registered) && (AbleContext.Current.User.IsAnonymous))
                {
                    RegisterPanel.Visible = true;
                    ReviewPanel.Visible   = false;
                }
                else
                {
                    //THE REVIEW FORM WILL BE ENABLED
                    User user = AbleContext.Current.User;
                    //CHECK TO SEE IF WE CAN PREPOPULATE THE FORM
                    ReviewerProfile profile = user.ReviewerProfile;
                    if (profile != null)
                    {
                        //EMAIL ADDRESS IS ONLY VISIBLE FOR ANONYMOUS USERS
                        trEmailAddress1.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        trEmailAddress2.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        Email.Text    = profile.Email;
                        Name.Text     = profile.DisplayName;
                        Location.Text = profile.Location;
                        //CHECK FOR EXISTING REVIEW
                        if (_ProductReview == null)
                        {
                            _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, profile.Id);
                        }
                        if (_ProductReview != null)
                        {
                            //EXISTING REVIEW FOUND, INITIALIZE FORM VALUES
                            //(THESE VALUES MAY BE OVERRIDEN BY FORM POST)
                            ListItem item = Rating.Items.FindByValue(_ProductReview.Rating.ToString("F0"));
                            if (item != null)
                            {
                                Rating.SelectedIndex = (Rating.Items.IndexOf(item));
                            }
                            ReviewTitle.Text = _ProductReview.ReviewTitle;
                            ReviewBody.Text  = _ProductReview.ReviewBody;
                        }
                    }
                    else if (!user.IsAnonymous)
                    {
                        trEmailAddress1.Visible = String.IsNullOrEmpty(GetUserEmail());
                        trEmailAddress2.Visible = String.IsNullOrEmpty(GetUserEmail());
                        Name.Text     = user.PrimaryAddress.FirstName;
                        Location.Text = user.PrimaryAddress.City;
                    }
                }
            }
            else
            {
                this.Controls.Clear();
            }
            this.FormInitialized = true;
        }
Ejemplo n.º 4
0
        private void BindReviews()
        {
            ReviewerProfile profile = AbleContext.Current.User.ReviewerProfile;

            if (profile != null)
            {
                ReviewsGrid.DataSource = ProductReviewDataSource.LoadForReviewerProfile(profile.Id, "ReviewDate DESC");
            }
            else
            {
                // EMPTY DATASET TO SHOW EMPTY GRID MESSAGE
                ReviewsGrid.DataSource = new List <ProductReview>();
            }
            ReviewsGrid.DataBind();
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ReviewerProfile profile = AbleContext.Current.User.ReviewerProfile;

            _ProductReviewId = AlwaysConvert.ToInt(Request.QueryString["ReviewId"]);
            _ProductReview   = ProductReviewDataSource.Load(_ProductReviewId);
            if (_ProductReview == null || _ProductReview.ReviewerProfileId != profile.Id)
            {
                Response.Redirect("~/Members/MyProductReviews.aspx");
            }
            _Product = ProductDataSource.Load(_ProductReview.ProductId);
            if (_Product == null)
            {
                Response.Redirect("~/Members/MyProductReviews.aspx");
            }
            ProductName.Text = _Product.Name;
            ProductReviewForm1.ReviewCancelled += new EventHandler(ProductReviewForm1_ReviewCancelled);
            ProductReviewForm1.ReviewSubmitted += new EventHandler(ProductReviewForm1_ReviewSubmitted);
        }
 private void UpdatePageIndex()
 {
     if (ReviewsGrid.Rows.Count > 0)
     {
         int startIndex = ((ReviewsGrid.PageIndex * ReviewsGrid.PageSize) + 1);
         int endIndex   = startIndex + ReviewsGrid.Rows.Count - 1;
         int rowCount   = ProductReviewDataSource.SearchCount(_ProductId, BitFieldState.True);
         ReviewsCaptionPanel.Visible = true;
         ReviewCount.Text            = string.Format(ReviewCount.Text, rowCount, ((rowCount > 1) ? "s" : ""));
         if (rowCount > ReviewsGrid.PageSize)
         {
             ReviewsCaption.Visible      = false;
             PagedReviewsCaption.Visible = true;
             int toIndex = startIndex + ReviewsGrid.PageSize - 1;
             if (toIndex > rowCount)
             {
                 toIndex = rowCount;
             }
             PagedReviewsCaption.Text = string.Format(PagedReviewsCaption.Text, startIndex, toIndex, rowCount);
         }
         else
         {
             ReviewsCaption.Visible      = true;
             PagedReviewsCaption.Visible = false;
             ReviewsCaption.Text         = string.Format(ReviewsCaption.Text, rowCount, ((rowCount > 1) ? "s" : ""));
         }
         AverageRatingPanel.Visible = true;
         ProductRating.Rating       = _Product.Rating;
         decimal rating = 0;
         if (_Product.Rating.HasValue)
         {
             rating = _Product.Rating.Value;
         }
         PHRichSnippets.Controls.Add(new LiteralControl(string.Format("<meta itemprop='ratingValue' content='{0}' />", rating)));
         PHRichSnippets.Controls.Add(new LiteralControl(string.Format("<meta itemprop='reviewCount' content='{0}' />", rowCount)));
     }
     else
     {
         ReviewsCaptionPanel.Visible = false;
         AverageRatingPanel.Visible  = false;
     }
 }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _ProductReviewId = AlwaysConvert.ToInt(Request.QueryString["ReviewId"]);
     _ProductReview   = ProductReviewDataSource.Load(_ProductReviewId);
     if (_ProductReview == null)
     {
         Response.Redirect("Default.aspx");
     }
     if (!Page.IsPostBack)
     {
         ReviewerProfile profile = _ProductReview.ReviewerProfile;
         ProductLink.NavigateUrl = string.Format(ProductLink.NavigateUrl, _ProductReview.ProductId);
         ProductLink.Text        = _ProductReview.Product.Name;
         ReviewDate.Text         = string.Format(ReviewDate.Text, _ProductReview.ReviewDate);
         Approved.Checked        = _ProductReview.IsApproved;
         ReviewerEmail.Text      = profile.Email;
         ReviewerName.Text       = profile.DisplayName;
         ReviewerLocation.Text   = profile.Location;
         Rating.Text             = string.Format(Rating.Text, _ProductReview.Rating);
         ReviewTitle.Text        = _ProductReview.ReviewTitle;
         ReviewBody.Text         = _ProductReview.ReviewBody;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _ProductReviewId = AlwaysConvert.ToInt(Request.QueryString["ReviewId"]);
            _ProductReview   = ProductReviewDataSource.Load(_ProductReviewId);

            if (_ProductReview != null)
            {
                _ProductId = _ProductReview.Product.Id;
            }
            else
            {
                _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            }
            _Product = ProductDataSource.Load(_ProductId);

            if (!Page.IsPostBack)
            {
                InitializeForm();
            }

            //INIT ReviewBody COUNTDOWN
            AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(ReviewBody, ReviewMessageCharCount);
            ReviewMessageCharCount.Text = ((int)(ReviewBody.MaxLength - ReviewBody.Text.Length)).ToString();
        }
        private bool SaveReview()
        {
            // SAVE REVIEWER PROFILE
            User user = AbleContext.Current.User;

            //MAKE SURE ANONYMOUS USER DOES NOT TRY TO USE REGISTERED USER EMAIL
            if (user.IsAnonymous)
            {
                IList <User> users = UserDataSource.LoadForEmail(Email.Text);
                if (users.Count > 0)
                {
                    CustomValidator invalidEmail = new CustomValidator();
                    invalidEmail.Text            = "*";
                    invalidEmail.ErrorMessage    = "Your email address is already registered.  You must log in to post the review.";
                    invalidEmail.IsValid         = false;
                    invalidEmail.ValidationGroup = "ProductReviewForm";
                    phEmailValidators.Controls.Add(invalidEmail);
                    return(false);
                }
                user.Save();
            }
            _Profile = user.ReviewerProfile;
            // TRY TO LOAD PROFILE BY EMAIL
            if (_Profile == null)
            {
                _Profile = ReviewerProfileDataSource.LoadForEmail(Email.Text);
                if (_Profile != null)
                {
                    if (_ProductReview == null)
                    {
                        _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id);
                    }

                    // ATTEMPT TO SUBMIT A 2ND REVIEW FOR THIS PRODUCT BY AN ANNONYMOUS USER
                    if (_ProductReview != null && String.IsNullOrEmpty(Request.Form[OverwriteReviewButton.UniqueID]))
                    {
                        // WARN THE USER THAT A REVIEW IS ALREADY SUBMITTED BY SAME EMAIL ADDRESS
                        CustomValidator reviewAlreadySubmitted = new CustomValidator();
                        reviewAlreadySubmitted.Text            = "*";
                        reviewAlreadySubmitted.ErrorMessage    = "You have already submitted a review for this product, do you want to overwrite your previous review?";
                        reviewAlreadySubmitted.IsValid         = false;
                        reviewAlreadySubmitted.ValidationGroup = "ProductReviewForm";
                        phEmailValidators.Controls.Add(reviewAlreadySubmitted);
                        OverwriteReviewButton.Visible = true;
                        SubmitReviewButton.Visible    = false;
                        return(false);
                    }
                }
            }
            if (_Profile == null)
            {
                _Profile = new ReviewerProfile();
            }
            _Profile.Email       = ((user.IsAnonymous && String.IsNullOrEmpty(GetUserEmail())) ? Email.Text : GetUserEmail());
            _Profile.DisplayName = StringHelper.StripHtml(Name.Text, true);
            _Profile.Location    = StringHelper.StripHtml(Location.Text, true);
            _Profile.Save();

            //IF PROFILE IS NULL, AN ERROR OCCURRED VALIDATING THE EMAIL
            if (_Profile != null)
            {
                //EITHER LOAD THE EXISTING REVIEW OR CREATE NEW
                if (_ProductReview == null)
                {
                    _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, _Profile.Id);
                }

                if (_ProductReview == null)
                {
                    _ProductReview = new ProductReview();
                }
                _ProductReview.ReviewerProfile = _Profile;
                _ProductReview.Product         = _Product;
                _ProductReview.ReviewDate      = LocaleHelper.LocalNow;
                _ProductReview.Rating          = AlwaysConvert.ToByte(Rating.SelectedValue);
                _ProductReview.ReviewTitle     = StringHelper.StripHtml(ReviewTitle.Text, true);
                _ProductReview.ReviewBody      = StringHelper.StripHtml(ReviewBody.Text, true);
                _ProductReview.Save(AbleContext.Current.User, true, true);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 10
0
        public void InitializeForm()
        {
            LoginLink.NavigateUrl = NavigationHelper.GetMobileStoreUrl(string.Format("~/Login.aspx?ReturnUrl={0}", Server.UrlEncode("ProductReviews.aspx?ProductId=" + _Product.Id)));

            StoreSettingsManager settings = AbleContext.Current.Store.Settings;

            if (settings.ProductReviewEnabled != UserAuthFilter.None && _Product.AllowReviews)
            {
                if ((settings.ProductReviewEnabled == UserAuthFilter.Registered) && (AbleContext.Current.User.IsAnonymous))
                {
                    RegisterPanel.Visible = true;
                    ReviewPanel.Visible   = false;
                }
                else
                {
                    //THE REVIEW FORM WILL BE ENABLED
                    User user = AbleContext.Current.User;
                    //DETERMINE IF WE NEED TO SUPPORT THE IMAGE CAPTCHA
                    trCaptcha.Visible = (ProductReviewHelper.ImageVerificationRequired(user));
                    if (trCaptcha.Visible)
                    {
                        //GENERATE A RANDOM NUMBER FOR IMAGE VERIFICATION
                        CaptchaImage.ChallengeText = StringHelper.RandomNumber(6);
                    }
                    //CHECK TO SEE IF WE CAN PREPOPULATE THE FORM
                    ReviewerProfile profile = user.ReviewerProfile;
                    if (profile != null)
                    {
                        //EMAIL ADDRESS IS ONLY VISIBLE FOR ANONYMOUS USERS
                        trEmailAddress1.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        trEmailAddress2.Visible = (user.IsAnonymous || String.IsNullOrEmpty(GetUserEmail()));
                        Email.Text    = profile.Email;
                        Name.Text     = profile.DisplayName;
                        Location.Text = profile.Location;
                        //CHECK FOR EXISTING REVIEW
                        if (_ProductReview == null)
                        {
                            _ProductReview = ProductReviewDataSource.LoadForProductAndReviewerProfile(_ProductId, profile.Id);
                        }
                        if (_ProductReview != null)
                        {
                            //EXISTING REVIEW FOUND, INITIALIZE FORM VALUES
                            //(THESE VALUES MAY BE OVERRIDEN BY FORM POST)
                            ListItem item = Rating.Items.FindByValue(_ProductReview.Rating.ToString("F0"));
                            if (item != null)
                            {
                                Rating.SelectedIndex = (Rating.Items.IndexOf(item));
                            }
                            ReviewTitle.Text = _ProductReview.ReviewTitle;
                            ReviewBody.Text  = _ProductReview.ReviewBody;
                        }
                    }
                    else if (!user.IsAnonymous)
                    {
                        trEmailAddress1.Visible = String.IsNullOrEmpty(GetUserEmail());
                        trEmailAddress2.Visible = String.IsNullOrEmpty(GetUserEmail());
                        Name.Text     = user.PrimaryAddress.FirstName;
                        Location.Text = user.PrimaryAddress.City;
                    }
                }
            }
            else
            {
                this.Controls.Clear();
            }
            this.FormInitialized = true;
        }
Ejemplo n.º 11
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     NoReviewsPanel.Visible = ProductReviewDataSource.SearchCount(_ProductId, BitFieldState.True) == 0;
 }
Ejemplo n.º 12
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (_product != null)
            {
                Page.Title              = string.IsNullOrEmpty(_product.Title) ? _product.Name : _product.Title;
                ProductName.Text        = _product.Name;
                moreDetails.NavigateUrl = NavigationHelper.GetMobileStoreUrl("~/ProductDescription.aspx?ProductId=" + _product.Id);
                if (_settings.MobileStoreProductUseSummary)
                {
                    ProductSummary.Text = _product.Summary;
                }
                else
                {
                    ProductSummary.Text = _product.Description;
                    if (string.IsNullOrEmpty(_product.ExtendedDescription))
                    {
                        moreDetails.Visible = false;
                    }
                    descriptionHeader.Visible = !string.IsNullOrEmpty(_product.Description);
                    moreDetails.Visible       = !string.IsNullOrEmpty(_product.Description);
                }
                if (_settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None)
                {
                    RatingPanel.Visible  = true;
                    ProductRating.Rating = _product.Rating;
                }
                if (_product.Manufacturer != null && !string.IsNullOrEmpty(_product.Manufacturer.Name))
                {
                    phManufacturer.Visible = true;
                    ManufLink.Text         = _product.Manufacturer.Name;
                    ManufLink.NavigateUrl  = Page.ResolveUrl(NavigationHelper.GetMobileStoreUrl(string.Format("~/Search.aspx?m={0}", _product.Manufacturer.Id)));
                }

                // PRODUCT REVIEWS
                if (_settings.ProductReviewEnabled != UserAuthFilter.None)
                {
                    int count = ProductReviewDataSource.SearchCount(_product.Id, BitFieldState.True);
                    if (count > 0)
                    {
                        ProductReviewsPanel.Visible = true;
                        ProductRatingStars1.Rating  = _product.Rating;
                        TotalReviews.Text           = count.ToString();
                        MoreDetailsLink.NavigateUrl = string.Format("ProductReviews.aspx?ProductId={0}", _product.Id);
                    }
                    else
                    {
                        NoReviewsPanel.Visible      = true;
                        averageRating.Visible       = false;
                        reviewsTotal.Visible        = false;
                        MoreDetailsLink.Text        = "Add Reviews";
                        MoreDetailsLink.NavigateUrl = string.Format("ProductReviews.aspx?ProductId={0}", _product.Id);
                    }
                }
                else
                {
                    ProductReviewsPanel.Visible = false;
                }

                //REGISTER THE PAGEVISIT
                AbleCommerce.Code.PageVisitHelper.RegisterPageVisit(_product.Id, CatalogNodeType.Product, _product.Name);
                AbleCommerce.Code.PageHelper.BindMetaTags(this, _product);
            }
        }