protected void Page_Load(object sender, EventArgs e) { var IsProduction = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsProduction"]); if (IsProduction) { if (Request.IsSecureConnection == false) { Response.Redirect(Request.Url.ToString().Replace("http://", "https://")); } } if (!IsPostBack) { var id = Request.QueryString["id"]; if (!string.IsNullOrEmpty(id)) { if (Helper.IsNumeric(id)) { ProductID = Int32.Parse(id); txtProductID.Value = ProductID.ToString(); try { product = controller.getProduct(ProductID); } catch (Exception ex) { throw ex; } ProductTitle.Text = product.ProductName; ProductDescription.Text = product.LongDescription; lblTotalCost.Text = String.Format("Order Total: {0:C}", product.ProductPrice); } else { Response.Redirect("http://www.myss.com/"); } } else { Response.Redirect("http://www.myss.com/"); } } else { } }
public MyssProduct getProduct(int ProductID) { DB db = new DB(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetProduct"; cmd.Parameters.AddWithValue("@ProductID", ProductID); DataTable dt = db.Execute(cmd); DataRow dr = dt.Rows[0]; MyssProduct product = new MyssProduct { LongDescription = dr["LongDescription"].ToString(), ShortDescrption = dr["ShortDescrption"].ToString(), ProductName = dr["ProductName"].ToString(), ProductID = Int32.Parse(dr["ProductID"].ToString()), ProductPrice = Double.Parse(dr["ProductPrice"].ToString()), }; return product; }
protected void RegisterButton_Click(object sender, ImageClickEventArgs e) { var id = txtProductID.Value; if (!string.IsNullOrEmpty(id)) { if (Helper.IsNumeric(id)) { ProductID = Int32.Parse(id); try { product = controller.getProduct(ProductID); } catch (Exception ex) { throw ex; } ProductPrice = Convert.ToInt32(product.ProductPrice); } else { Response.Redirect("http://www.myss.com/"); } } var amt = 0; try { if (controller.EmailExists(EmailTextBox.Text.Trim(), ProductID)) { lblErrorMessage.Text = "You have already signed up for this class."; ClassLogin.Visible = true; return; } int charge = ProductPrice; if (charge > 0) { CreateCharge(out amt, charge); UserTransaction transaction = new UserTransaction { ProductID = product.ProductID, FirstName = FirstNameTextBox.Text, LastName = LastNameTextBox.Text, Email = EmailTextBox.Text, Password = PasswordTextBox.Text, Address = AddressTextBox.Text, City = CityTextBox.Text, Zip = ZipTextBox.Text, State = State.SelectedValue, Phone = PhoneNumberTextBox.Text, Amount = Convert.ToDecimal(charge) }; try { controller.SaveUserTransaction(transaction); Util.SendWelcomeMail(transaction, product); String s = "product_thankyou.aspx?id=" + ProductID; Response.Redirect(s); } catch (Exception ex) { string error = ex.Message; lblErrorMessage.Text = "Unable to create customer record, please contact myss.com support. "; return; } } } catch (Exception ex) { string error = ex.Message; lblErrorMessage.Text = "Unable to process your credit card. Please verify the information or try another card. "; return; } }
public static void SendWelcomeMail(UserTransaction transaction, MyssProduct product) { var InfoEmail = System.Configuration.ConfigurationManager.AppSettings["InfoEmail"]; var CustServiceEmail = System.Configuration.ConfigurationManager.AppSettings["CustServiceEmail"]; var TestInfoEmail = System.Configuration.ConfigurationManager.AppSettings["TestInfoEmail"]; var TestCustServiceEmail = System.Configuration.ConfigurationManager.AppSettings["TestCustServiceEmail"]; var sb = new StringBuilder(); sb.Append("Name: ").Append(transaction.FirstName).Append(" ").AppendLine(transaction.LastName); sb.Append("Email: ").AppendLine(transaction.Email); sb.Append("Address: ").AppendLine(transaction.Address); sb.Append("City: ").AppendLine(transaction.City); sb.Append("State: ").AppendLine(transaction.State); sb.Append("Zip: ").AppendLine(transaction.Zip); sb.Append("Phone: ").AppendLine(transaction.Phone); sb.Append("Amount Paid: $").AppendLine(product.ProductPrice.ToString()); sb.AppendLine(); sb.Append("Product Purchased: ").AppendLine(product.ProductName.ToUpper()); sb.AppendLine(); sb.Append("This is confirmation of your purchase of the Caroline Myss Reflection Class."); sb.Append("You will receive e-mail instructions to view this class 48 hours prior to the live class."); sb.Append("If you have any questions please e-mail at: [email protected]"); var sbAdmin = new StringBuilder(); sbAdmin.Append("Name: ").Append(transaction.FirstName).Append(" ").AppendLine(transaction.LastName); sbAdmin.Append("Email: ").AppendLine(transaction.Email); sbAdmin.Append("Address: ").AppendLine(transaction.Address); sbAdmin.Append("City: ").AppendLine(transaction.City); sbAdmin.Append("State: ").AppendLine(transaction.State); sbAdmin.Append("Zip: ").AppendLine(transaction.Zip); sbAdmin.Append("Phone: ").AppendLine(transaction.Phone); sbAdmin.Append("Amount Paid: $").AppendLine(product.ProductPrice.ToString()); sbAdmin.AppendLine(); sbAdmin.Append("Product Purchased: ").AppendLine(product.ProductName.ToUpper()); var isTest = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestMode"]); var IsTestEmailDelivery = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestEmailDelivery"]); var TestString = String.Empty; if (isTest) { TestString = " - Testing Please Ignore"; } if (IsTestEmailDelivery) { SendMail(transaction.Email, TestCustServiceEmail, "Welcome to Myss.com Reflections Classes" + TestString, sb.ToString(), false); SendMail(TestCustServiceEmail, TestInfoEmail, "New Myss.com Reflections Customer" + TestString, sbAdmin.ToString(), false); } else { SendMail(transaction.Email, CustServiceEmail, "Welcome to Myss.com Reflections Classes" + TestString, sb.ToString(), false); SendMail(CustServiceEmail, InfoEmail, "New Myss.com Reflections Customer" + TestString, sbAdmin.ToString(), false); } }