コード例 #1
0
        //Called when the user click the about/testimonials page
        public ActionResult Testimonials(FormCollection form)
        {
            ViewData["thankyou"] = ""; //initialize thank you response

            categoryList = new List <string>();

            //Get all catagories from db and store them in a view variable
            Book.SelectDistinctCategories(categoryList);
            ViewData["categories"] = categoryList;

            bool fchk = false;

            if ((form["name0"] != null) && (form["issue0"] != null))
            {
                fchk = true;
            }

            bool   trial = false;
            string name  = form["name0"];
            string entry = form["issue0"];

            Customer tmpCustomer = new Customer();

            //Check to see if a customer is logged in and try to insert testimonial
            if ((Session["custId"] != null) && (fchk == true))
            {
                Testimonial report = new Testimonial();
                trial = report.InsertTestimonial((int)Session["custId"], name, entry);
            }

            if (trial == true)
            {
                ViewData["thankyou"] = "Thanks for submitting! We will review your testimonial.";
                return(View()); // still need to create thank you view
            }
            else
            {
                return(View());
            }
        }