protected void RegisterUserButton_Click(object sender, EventArgs e) { FullAddress = txtStreet.Text + "," + txtCity.Text + "," + txtState.Text + "," + txtZip.Text; FullBillingAddress = txtBillingStreet.Text + "," + txtBillingCity.Text + "," + txtBillingState.Text + "," + txtBillingZip.Text; string CustomerFirstName = txtFirstName.Text; string CustomerLastName = txtLastName.Text; string CustomerPhoneNumber = txtPhoneNumber.Text; string CustomerEmail = txtEmail.Text; string CustomerPassword = txtPassword.Text; string CustomerDeliveryAddress = FullAddress; string CustomerBillingAddress = FullBillingAddress; string RestaurantEmail = txtEmail.Text; string RestaurantPassword = txtPassword.Text; string RestaurantFirstName = txtFirstName.Text; string RestaurantLastName = txtLastName.Text; string RestaurantCuisine = ddlCuisine.SelectedValue.ToString(); string RestaurantImgUrl = txtImgUrl.Text; string RestaurantLocation = FullAddress; string restaurantName = txtRestuarantName.Text; string RestaurantPhoneNumber = txtPhoneNumber.Text; string SecurityQuestion = txtSecurityQuestion.Text; string SecurityAnswer = txtAnswer.Text; //Validate ValidateUserRegistration(); if ((UserRegistrationError.Count == 0) && (ddlUserTypeID.SelectedValue == "Customer")) { //Check if email already exist String UserEmail = txtEmail.Text; Boolean flag = CheckIfCustomerExists(UserEmail); if (flag == true) { Response.Write("Email already exist"); } else { Merchant m12 = new Merchant(); APIKey w12 = new APIKey(); VWHolder VW12 = new VWHolder(); VW12.Name = txtFirstName.ToString() + "" + txtLastName.ToString(); VW12.Password = txtPassword.ToString(); VW12.Email = txtEmail.ToString(); VW12.AccountNumber = "12345679023"; string test = ExecuteCallToWebAPI(VW12, m12, w12); //Register Customer newCustomer = new Customer { FirstName = CustomerFirstName, LastName = CustomerLastName, PhoneNumber = CustomerPhoneNumber, Email = CustomerEmail, Password = CustomerPassword, DeliveryAddress = CustomerDeliveryAddress, BillingAddress = CustomerBillingAddress, SecurityAnswer = SecurityAnswer, SecurityQuestion = SecurityQuestion, VWID = test }; var ResponseReceived = newCustomer.AddCustomer(); if (ResponseReceived == true) { //User Registered //Save UserEmail in Session Called UserEmail Session.Add("userEmail", txtEmail.Text.ToString()); Session.Add("userPassword", txtPassword.Text.ToString()); Session.Add("userVWID", test); RegisterUserDetails.Visible = false; PreferencesDiv.Visible = true; } else { Response.Write("Error Occured on the DATABASE"); } } } if ((UserRegistrationError.Count == 0) && (ddlUserTypeID.SelectedValue == "Restaurant")) { //Check if email already exist String UserEmail = txtEmail.Text; Boolean flag = CheckIfRestaurantExists(UserEmail); if (flag == true) { Response.Write("Email already exist"); } else { Merchant m12 = new Merchant(); APIKey w12 = new APIKey(); VWHolder VW12 = new VWHolder(); VW12.Name = txtFirstName.ToString() + "" + txtLastName.ToString(); VW12.Password = txtPassword.ToString(); VW12.Email = txtEmail.ToString(); VW12.AccountNumber = "12345679023"; string test = ExecuteCallToWebAPI(VW12, m12, w12); //Register Restaurants newRestaurants = new Restaurants { Email = RestaurantEmail, Password = RestaurantPassword, FirstName = RestaurantFirstName, LastName = RestaurantLastName, Cuisine = RestaurantCuisine, ImgURL = RestaurantImgUrl, PhoneNumber = RestaurantPhoneNumber, RestaurantName = restaurantName, Location = RestaurantLocation, SecurityAnswer = SecurityAnswer, SecurityQuestion = SecurityQuestion, VWID = test }; var ResponseReceived = newRestaurants.AddAddRestaurant(); if (ResponseReceived == true) { //User Registered //Save UserEmail in Session Called UserEmail Session.Add("userEmail", txtEmail.Text.ToString()); Session.Add("userPassword", txtPassword.Text.ToString()); Session.Add("userVWID", test); RegisterUserDetails.Visible = false; PreferencesDiv.Visible = true; Email objEmail = new Email(); String strTO = txtEmail.Text.ToString(); String strFROM = "*****@*****.**"; String strSubject = "Thank you for signing up to our website!"; String strMessage = "We hope that you are able to find many customers!"; try { objEmail.SendMail(strTO, strFROM, strSubject, strMessage); Response.Write("The email was sent."); } catch (Exception ex) { Response.Write("The email wasn't sent because one of the required fields was missing."); } } else { Response.Write("Error Occured on the DATABASE"); } } } else { for (int i = 0; i < UserRegistrationError.Count; i++) { Response.Write(UserRegistrationError[i] + "<br/>"); } } }