Ejemplo n.º 1
0
        protected void AddCustomer_Click(object sender, EventArgs e)
        {
            customer = new Customer();
            SetCustomerReg(customer);//set textbox value to object customer,password has been md5ed


            try

            {
                if (CustomerDB.checkUserId(txtUserName.Text))               //check username is registered or not
                {
                    customer.CustomerId = CustomerDB.AddCustomer(customer); //get existed customerID
                    lblError.Text       = "This UserName has been registered!";
                }
                else
                {
                    CustomerDB.AddCustomer(customer);//insert new customer
                    lblError.Text = "You have successfully registered!";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //add a new record to database
        protected void txtRegister_Click(object sender, EventArgs e)
        {
            customer = new Customer();
            this.PutCustomerData(customer);
            try
            {
                if (CustomerDB.checkUserId(txtUserName.Text))
                {
                    customer.CustomerId = CustomerDB.AddCustomer(customer);

                    Session["user"] = customer.CustUserID;//assign userId of customer to a session variable


                    Response.Redirect("~/Manage.aspx");
                }
                else
                {
                    lblError.Text = "UserId " + txtUserName.Text + " is already existed!";
                }
            }
            catch (Exception ex)
            {
                lblError.Text = (ex.Message + ex.GetType().ToString());
            }
        }
        public void TestUpdateCustomer()
        {
            /*Create the test variables.*/
            Customer oldCustomer = new Customer();

            oldCustomer.Name    = "Mickey Mouse";
            oldCustomer.Address = "101 Main Street";
            oldCustomer.City    = "Orlando";
            oldCustomer.State   = "FL";
            oldCustomer.ZipCode = "10101";
            int customerID = CustomerDB.AddCustomer(oldCustomer);

            oldCustomer = CustomerDB.GetCustomer(customerID);

            Customer newCustomer = new Customer();

            newCustomer.Name    = "Minnie Mouse";
            newCustomer.Address = "123 Dream Street";
            newCustomer.City    = "Anaheim";
            newCustomer.State   = "CA";
            newCustomer.ZipCode = "01010";

            /* Test the command.*/
            bool isCustomerUpdated = CustomerDB.UpdateCustomer(oldCustomer, newCustomer);

            /* If it affected the database in some way, the test was successful. */
            Assert.AreEqual(true, isCustomerUpdated);
            /* Clean up the test.*/
            newCustomer = CustomerDB.GetCustomer(customerID);
            CustomerDB.DeleteCustomer(newCustomer);
        }
Ejemplo n.º 4
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            CustomerDB.AddCustomer(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text);
            Customer customer = CustomerDB.GetCustomer(TextBox5.Text);

            Session["ID"] = customer.ID;
            Response.Redirect("Account.aspx");
        }
Ejemplo n.º 5
0
        public void AddCustomerWorks()
        {
            using (var context = new Entity.p0storeContext(options)){
                CustomerDB _customerDB = new CustomerDB(context);
                _customerDB.AddCustomer(new Model.Customer("john doe", "johndoe"));
            }

            using (var assertContext = new Entity.p0storeContext(options)){
                var customer = assertContext.Customers.FirstOrDefault(cust => cust.Username == "johndoe");
                Assert.NotNull(customer);
                Assert.Equal("john doe", customer.Name);
            }
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName  = model.Email,
                    Email     = model.Email,
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Phone     = model.Phone,
                    City      = model.City
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    /*
                     * MessageBox.Show("model.FirstName=" + model.FirstName);
                     * MessageBox.Show("model.LastName=" + model.LastName);
                     * MessageBox.Show("model.Phone=" + model.Phone);
                     * MessageBox.Show("model.City=" + model.City);
                     * MessageBox.Show("model.Email=" + model.Email);
                     * MessageBox.Show("model.Password="******"Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 7
0
 public IActionResult SignUp(Customer cus)
 {
     // Validate input
     if (ModelState.IsValid)
     {
         if (CustomerDB.AddCustomer(cus))
         {
             ViewData["Msg"] = "Thank you " +
                               cus.FirstName + " " + cus.LastName +
                               ", your information was added to the data base.";
         }
         else
         {
             ViewData["Msg"] = "Sorry, there was an error with adding you, " +
                               "try again later.";
         }
     }
     return(View(cus));
 }
        public void TestDeleteCustomer()
        {
            /*Create the test variables.*/
            Customer c = new Customer();

            c.Name    = "Mickey Mouse";
            c.Address = "101 Main Street";
            c.City    = "Orlando";
            c.State   = "FL";
            c.ZipCode = "10101";
            int customerID = CustomerDB.AddCustomer(c);

            c = CustomerDB.GetCustomer(customerID);

            /* Test the command.*/
            bool isCustomerDeleted = CustomerDB.DeleteCustomer(c);

            /* If it affected the database in some way, the test was successful. */
            Assert.AreEqual(true, isCustomerDeleted);
        }
        public void TestAddCustomer()
        {
            /*Create the test variables.*/
            Customer c = new Customer();

            c.Name    = "Mickey Mouse";
            c.Address = "101 Main Street";
            c.City    = "Orlando";
            c.State   = "FL";
            c.ZipCode = "10101";

            /* Test the command.*/
            int customerID = CustomerDB.AddCustomer(c);

            c = CustomerDB.GetCustomer(customerID);
            /* If the test subject has a name within the database, the test was successful. */
            Assert.AreEqual("Mickey Mouse", c.Name);
            /*Clean up the test*/
            CustomerDB.DeleteCustomer(c);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();

            customer.CustFirstName = txtFirstName.Text;
            customer.CustLastName  = txtLastName.Text;
            customer.CustAddress   = txtAddress.Text;
            customer.CustCity      = txtCity.Text;
            customer.CustProv      = ddlProvince.SelectedValue;
            customer.CustCountry   = txtCountry.Text;
            customer.CustPostal    = txtPostal.Text.ToUpper();
            customer.CustEmail     = txtEmail.Text;
            customer.CustHomePhone = txtHomePhone.Text.Replace("(", "").Replace(")", "").Replace("-", "");
            customer.CustBusPhone  = txtBusinessPhone.Text.Replace("(", "").Replace(")", "").Replace("-", "");
            customer.CustUsername  = txtUsername.Text;
            customer.CustPassword  = txtPassword1.Text;
            customer.CustFirstName = txtFirstName.Text;

            CustomerDB.AddCustomer(customer);
            Response.Redirect("Homepage.aspx");
        }
Ejemplo n.º 11
0
        //confirmation method for button
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            int insert = 0;
            // new customer object and add to active session
            Customer customer = (Customer)Session["Customer"];

            insert = CustomerDB.AddCustomer(customer);

            if (insert == 1)
            {
                lblMessage.Text = "Thank you for your Registration.<br />" +
                                  "Please log in at the login page";
            }
            else
            {
                lblMessage.Text = "Thank you for your Registration.< br /> " +
                                  "Please log in at the login page";
            }


            Response.Redirect("login.aspx");
        }
Ejemplo n.º 12
0
        //submit button to insert(register) new customer information
        protected void uxSubmit_Click(object sender, EventArgs e)
        {
            string un = Convert.ToString(uxUsername.Text);
            if (CustomerDB.CheckUserName(un))
            {
                var cust = new Customer
                {
                    UserName = uxUsername.Text,
                    Password = uxPassword.Text,
                    CustFirstName = uxFirstName.Text,
                    CustLastName = uxLastName.Text,
                    CustAddress = uxAddress.Text,
                    CustCity = uxCity.Text,
                    CustProv = DropDownList1.Text,
                    CustPostal = uxPostal.Text,
                    CustCountry = uxCountry.Text,
                    CustHomePhone = uxHomePhone.Text,
                    CustBusPhone = uxBusPhone.Text,
                    CustEmail = uxEmail.Text
                   
                };

                int CustID = CustomerDB.AddCustomer(cust);
                // create a customer session 
                Session["Customer"] = cust;
                Response.Redirect("~/CustomerOrders.aspx");
            }
            else
            {
                Session["Customer"] = null;
                //Response.Write("UserName is already exist,please try another one.");
                Response.Write("<script>alert('UserName is already exist,please try another one.')</script>");
            }


        }//end of sumit button
Ejemplo n.º 13
0
        public IActionResult Register(IFormCollection data)
        {
            Customer cus = new Customer();

            cus.FirstName = data["FirstName"];
            cus.LastName  = data["LastName"];
            cus.Password  = data["Password"];
            cus.Email     = data["Email"];
            cus.PhoneNum  = Convert.ToInt32(data["PhoneNum"]);

            if (CustomerDB.AddCustomer(cus))
            {
                ViewData["Msg"] = "Thank you " +
                                  cus.FirstName + " " + cus.LastName +
                                  ", your information was added to the data base.";
            }
            else
            {
                ViewData["Msg"] = "Sorry, there was an error with adding you, " +
                                  "try again later.";
            }

            return(View());
        }
Ejemplo n.º 14
0
 public Customer AddCustomer(Customer newCustomer)
 {
     return(_customerDB.AddCustomer(newCustomer));
 }