Exemplo n.º 1
0
        protected void btnSaveReview_Click(object sender, EventArgs e)
        {
            string response = "";

            if (Convert.ToString(Session["UserId"]) == "" && Session["UserId"] == null)
            {
                Session["Source"]  = "Review";
                Session["Ratings"] = tbRating.Text;
                Session["Review"]  = tbReview.Text;
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "alert('Login first.');window.location ='Login.aspx'", true);
            }
            else
            {
                Review review = new Review();
                review.ProductId = Convert.ToInt32(Session["ProductId"]);
                review.UserId    = Convert.ToInt32(Session["UserId"]);
                review.Star      = Convert.ToInt32(tbRating.Text);
                review.Review1   = tbReview.Text;
                review.Date      = DateTime.Now;

                response = productServices.AddReview(review);
                if (response == "Success")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Success','Review is added.')", true);
                    Clear();
                    DisplayDetails(Convert.ToInt32(Session["ProductId"]));
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Error!','" + response + "')", true);
                }
            }
        }