예제 #1
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();

            CustomerRegistration register = new CustomerRegistration();

            register.CustEmail = Email.Text.Replace(" ", "");

            int CustomerID = CustomerRegistrationDB.EmailRegistration(register);

            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var user          = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text
            };
            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                //string code = manager.GenerateEmailConfirmationToken(user.Id);
                //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
예제 #2
0
 //the functio is used to fill data in the object of CustomerRegistration
 protected void FillData()
 {
     cr = new CustomerRegistration();
     GettingCustomerID();
     cr = CustomerRegistrationDB.GetCustomers(Convert.ToInt32(Session["UserID"]));
     txtFirstName.Text = cr.CustFirstName;
     txtLastName.Text  = cr.CustLastName;
     txtAddress.Text   = cr.CustAddress;
     txtCity.Text      = cr.CustCity;
     txtCountry.Text   = cr.CustCountry;
     txtProv.Text      = cr.CustProv;
     txtPostal.Text    = cr.CustPostal;
     txtBusPhone.Text  = cr.CustBusPhone;
     txtHomePhone.Text = cr.CustHomePhone;
     txtEmailID.Text   = cr.CustEmail;
 }
예제 #3
0
        //function fires when clicked on save button
        protected void Register_Click(object sender, EventArgs e)
        {
            //cr = new CustomerRegistration();
            GettingCustomerID();
            //create 2 objects of CustomerRegistration
            CustomerRegistration oldCust = new CustomerRegistration();
            CustomerRegistration newCust = new CustomerRegistration();

            //get data from the fields
            oldCust.CustomerID    = Convert.ToInt32(Session["UserID"]);
            newCust.CustFirstName = txtFirstName.Text;
            newCust.CustLastName  = txtLastName.Text;
            newCust.CustAddress   = txtAddress.Text;
            newCust.CustCity      = txtCity.Text;
            newCust.CustProv      = txtProv.Text;
            newCust.CustPostal    = txtPostal.Text;
            newCust.CustCountry   = txtCountry.Text;
            newCust.CustBusPhone  = txtBusPhone.Text;
            newCust.CustHomePhone = txtHomePhone.Text;
            newCust.CustEmail     = txtEmailID.Text;

            try
            {
                //call the function to update the Customer
                if (!CustomerRegistrationDB.updateCustomer(oldCust, newCust))
                {
                    lblSuccess.Text = "PLease enter a valid data";
                }
                else
                {
                    cr = newCust;
                    lblSuccess.Visible = true;
                }
            }
            catch (Exception ex)
            {
                lblSuccess.Text = "PLease enter a valid data";
            }
        }