Esempio n. 1
0
 protected string GenContactDetailLink(Contact c)
 {
     return "ContactDetails.aspx?id=" + c.contactID.ToString();
 }
Esempio n. 2
0
        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            MembershipCreateStatus createStatus;
            MembershipUser newUser = Membership.CreateUser(TextBoxEmail.Text, TextBoxPassword.Text, TextBoxEmail.Text, null, null, true, out createStatus);
            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "The user account was successfully created! ";

                    try
                    {
                        var contact = new Contact() {
                            firstName = TextBoxFirstName.Text,
                            lastName = TextBoxLastName.Text,
                            email = TextBoxEmail.Text,
                            phone = txtContactPhone.Text,
                            userID = (Guid)newUser.ProviderUserKey
                        };

                        theGateContext.Contacts.Add(contact);
                        theGateContext.SaveChanges();

                        if (Membership.ValidateUser(TextBoxEmail.Text.Trim(), TextBoxPassword.Text))
                        {
                            FormsAuthenticationTicket tkt;
                            string cookiestr;
                            HttpCookie ck;
                            tkt = new FormsAuthenticationTicket(TextBoxEmail.Text.Trim(), true, 30);
                            cookiestr = FormsAuthentication.Encrypt(tkt);
                            ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                            ck.Expires = tkt.Expiration;
                            ck.Path = FormsAuthentication.FormsCookiePath;
                            Response.Cookies.Add(ck);

                            Response.Redirect("~/Profile.aspx?NewUser=Yes", true);
                        }

                        // Not valid login throw exception
                    }
                    catch (Exception ex)
                    {
                        PanelRegisterAlertError.Visible = true;
                        LabelRegisterAlert.Text = ex.Message;
                            //+ " " + ((ex.InnerException != null) ? ex.InnerException.Message : "");
                    }
                    break;
                case MembershipCreateStatus.DuplicateUserName:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "There already exists a user with this email address/username.  Please contact [email protected].";
                    break;
                case MembershipCreateStatus.DuplicateEmail:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "There already exists a user with this email address/username.  Please contact [email protected].";
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "There email address provided is not valid.  Please correct and try again.";
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "There security answer was invalid.";
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "The password provided is not valid. Passwords are required to be at least 6 characters long.";
                    break;
                default:
                    PanelRegisterAlertError.Visible = true;
                    LabelRegisterAlert.Text = "There was an unknown error; the user account has not created.";
                    break;
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                // add contact setup
                ButtonContactAction.Text = "Add Contact";
                ButtonContactAction.Click += ButtonContactActionAdd_Click;
                pnlAddresses.Visible = false;
                return;
            }

            int i = int.Parse(Request.QueryString["id"] != null ? Request.QueryString["id"] : "0");
            ContactA = theGateContext.Contacts.FirstOrDefault(c => c.contactID == i);

            if (ContactA == null)
            {
                ShowError("Contact not found.");
                PanelContactForm.Visible = false;
                return;
            }

            ButtonContactAction.Text = "Update Contact";
            ButtonContactAction.Click += ButtonContactActionUpdate_Click;

            if (Page.IsPostBack)
                return;

            txtContactFirstName.Text = ContactA.firstName;
            txtContactLastName.Text = ContactA.lastName;
            txtContactEmail.Text = ContactA.email;
            txtContactPhone.Text = ContactA.phone;
            txtContactFax.Text = ContactA.fax;

            if (ContactA.shippingAddress != null)
            {
                pnlShippingAddress.Visible = true;
                buttonAddShippingAddress.Visible = false;
                txtShippingAddress1.Text = ContactA.Address.line1;
                txtShippingAddress2.Text = ContactA.Address.line2;
                txtShippingCity.Text = ContactA.Address.city;
                ddlShippingProvince.SelectedValue = ContactA.Address.state;
                txtShippingPostalCode.Text = ContactA.Address.zipcode;
                ckbSameAsShipping.Enabled = true;
            }

            if (ContactA.billingAddress != null)
            {
                pnlBillingAddress.Visible = true;
                buttonAddBillingAddress.Visible = false;
                if (contact.shippingAddress == ContactA.billingAddress)
                {
                    ckbSameAsShipping.Checked = true;
                    pnlBillingAddressDetails.Enabled = false;
                }
                else
                {
                    txtBillingAddress1.Text = ContactA.Address1.line1;
                    txtBillingAddress2.Text = ContactA.Address1.line2;
                    txtBillingCity.Text = ContactA.Address1.city;
                    ddlBillingProvince.SelectedValue = ContactA.Address1.state;
                    txtBillingPostalCode.Text = ContactA.Address1.zipcode;
                }
            }

            if (ContactA.shippingAddress == ContactA.billingAddress)
            {
                ckbSameAsShipping.Checked = true;
                pnlBillingAddressDetails.Enabled = false;
            }

            if (Page.IsPostBack)
                return;
        }
Esempio n. 4
0
 private void ButtonContactActionAdd_Click(object sender, EventArgs e)
 {
     var newContact = new Contact();
     newContact = LoadContact(newContact);
     theGateContext.Contacts.Add(newContact);
     theGateContext.SaveChanges();
     Response.Redirect("ContactDetails.aspx?id=" + newContact.contactID);
 }
Esempio n. 5
0
 public SitePage()
 {
     _theGateContext = new TheGateContext();
     var userID = Membership.GetUser() != null ? (Guid)Membership.GetUser().ProviderUserKey : Guid.Empty;
     _contact = theGateContext.Contacts.Where(c => c.userID == userID).FirstOrDefault();
 }