示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool            error             = false;
            int             reviewerProfileId = AlwaysConvert.ToInt(Request.QueryString["Reviewer"]);
            ReviewerProfile profile           = ReviewerProfileDataSource.Load(reviewerProfileId);

            if (profile != null)
            {
                if (!profile.EmailVerified)
                {
                    Guid code = AlwaysConvert.ToGuid(Request.QueryString["Code"]);
                    if (profile.EmailVerificationCode == code)
                    {
                        //VERIFY THIS USER
                        profile.VerifyEmail();
                    }
                    else
                    {
                        error = true;
                    }
                }
            }
            else
            {
                error = true;
            }
            SuccessText.Text    = SuccessMessage;
            SuccessText.Visible = !error;
            FailureText.Text    = FailureMessage;
            FailureText.Visible = error;
        }
        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;
        }
示例#3
0
 protected void ReviewsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DoDelete")
     {
         ReviewerProfile profile = AbleContext.Current.User.ReviewerProfile;
         int             index   = profile.ProductReviews.IndexOf(AlwaysConvert.ToInt(e.CommandArgument));
         if (index > -1)
         {
             profile.ProductReviews.DeleteAt(index);
         }
         BindReviews();
     }
 }
示例#4
0
        private void BindReviews()
        {
            ReviewerProfile profile = AbleContext.Current.User.ReviewerProfile;

            if (profile != null)
            {
                ReviewsGrid.DataSource = profile.ProductReviews;
            }
            else
            {
                // empty dataset to show empty grid message
                ReviewsGrid.DataSource = new List <ProductReview>();
            }
            ReviewsGrid.DataBind();
        }
示例#5
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();
        }
示例#6
0
        private void Save()
        {
            //FIRST UPDATE THE PROFILE
            ReviewerProfile profile = _ProductReview.ReviewerProfile;

            profile.Email       = ReviewerEmail.Text;
            profile.DisplayName = ReviewerName.Text;
            profile.Location    = ReviewerLocation.Text;
            profile.Save();
            //NEXT UPDATE THE REVIEW
            _ProductReview.IsApproved  = Approved.Checked;
            _ProductReview.ReviewTitle = ReviewTitle.Text;
            _ProductReview.ReviewBody  = ReviewBody.Text;
            _ProductReview.Save();
            SuccessMessage.Text    = string.Format(SuccessMessage.Text, LocaleHelper.LocalNow);
            SuccessMessage.Visible = true;
        }
示例#7
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);
        }
示例#8
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;
     }
 }
        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);
        }
示例#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;
        }