//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(); } }
public ActionResult CompleteCheckOut() { int custId = (int)Session["custId"]; Customer tmpCustomer = new Customer(); tmpCustomer.SelectByAttr("customer_id", custId); return View(tmpCustomer); }
//Called when a customer clicks the account tab public ActionResult Customer() { categoryList = new List<string>(); Customer tmpCustomer = new Customer(); //Get all catagories from db and store them in a view variable Book.SelectDistinctCategories(categoryList); ViewData["categories"] = categoryList; //Check to see if a customer is logged in if (Session["custId"] != null) { //Gets a customer row from the db with the specified customer id tmpCustomer.SelectByAttr("customer_id", (int)Session["custId"]); ViewData["status"] = "Customer profile for: " + tmpCustomer.f_name; } else { ViewData["status"] = "Please login to view account profile."; } return View(tmpCustomer); }
public static void SelectAllByAttr(string id, string attribute, List<Customer> custList) { Database db = new Database(); OleDbDataReader reader; db.Open(); reader = db.Read("select * from customer where " + attribute + " = '" + id + "'"); if (reader.Read()) { Customer tmpCustomer = new Customer(); tmpCustomer.id = Convert.ToInt32(reader.GetValue(0)); tmpCustomer.l_name = reader.GetString(1).Trim(); tmpCustomer.f_name = reader.GetString(2).Trim(); tmpCustomer.address = reader.GetString(3).Trim(); tmpCustomer.city = reader.GetString(4).Trim(); tmpCustomer.state = reader.GetString(5).Trim(); tmpCustomer.zip = Convert.ToInt32(reader.GetValue(6)); tmpCustomer.region = reader.GetString(7).Trim(); tmpCustomer.email = reader.GetString(8).Trim(); tmpCustomer.login_name = reader.GetString(9).Trim(); tmpCustomer.login_pass = reader.GetString(10).Trim(); custList.Add(tmpCustomer); } db.Close(); }