public void SaveData() { ClientCartContext clientData = ClientOrderData; if (Page.IsValid) { Customer CustData = new Customer(); //Set Customer Information Address shippingAddress = new Address(); shippingAddress.FirstName = CommonHelper.fixquotesAccents(txtShippingFirstName.Text); shippingAddress.LastName = CommonHelper.fixquotesAccents(txtShippingLastName.Text); shippingAddress.Address1 = CommonHelper.fixquotesAccents(txtShippingAddress1.Text); shippingAddress.Address2 = CommonHelper.fixquotesAccents(txtShippingAddress2.Text); shippingAddress.City = CommonHelper.fixquotesAccents(txtShippingCity.Text); shippingAddress.StateProvinceId = Convert.ToInt32(ddlShippingState.SelectedValue); shippingAddress.CountryId = CountryManager.CountryId("United States"); shippingAddress.ZipPostalCode = CommonHelper.fixquotesAccents(txtShippingZipCode.Text); CustData.ShippingAddress = shippingAddress; CustData.FirstName = CommonHelper.fixquotesAccents(txtShippingFirstName.Text); CustData.LastName = CommonHelper.fixquotesAccents(txtShippingFirstName.Text); CustData.PhoneNumber = txtPhoneNumber1.Text;// +txtPhoneNumber2.Text + txtPhoneNumber3.Text; CustData.Email = CommonHelper.fixquotesAccents(txtEmail.Text); CustData.Username = CommonHelper.fixquotesAccents(txtEmail.Text); //CustData.ShippingAddress = billingAddress; if (!pnlShippingAddress.Visible) { CustData.BillingAddress = shippingAddress; } else { Address billingAddress = new Address(); billingAddress.FirstName = CommonHelper.fixquotesAccents(txtFirstName.Text); billingAddress.LastName = CommonHelper.fixquotesAccents(txtLastName.Text); billingAddress.Address1 = CommonHelper.fixquotesAccents(txtAddress1.Text); billingAddress.Address2 = CommonHelper.fixquotesAccents(txtAddress2.Text); billingAddress.City = CommonHelper.fixquotesAccents(txtCity.Text); billingAddress.StateProvinceId = Convert.ToInt32(ddlState.SelectedValue); billingAddress.CountryId = CountryManager.CountryId("United States"); billingAddress.ZipPostalCode = CommonHelper.fixquotesAccents(txtZipCode.Text); CustData.BillingAddress = billingAddress; } PaymentInformation paymentDataInfo = new PaymentInformation(); string CardNumber = ucTokenex.ReceivedToken; paymentDataInfo.CreditCardNumber = CommonHelper.Encrypt(CardNumber); paymentDataInfo.CreditCardType = Convert.ToInt32(ddlCCType.SelectedValue); paymentDataInfo.CreditCardName = ddlCCType.SelectedItem.Text; paymentDataInfo.CreditCardExpired = new DateTime(int.Parse(ddlExpYear.SelectedValue), int.Parse(ddlExpMonth.SelectedValue), 1); paymentDataInfo.CreditCardCSC = CommonHelper.Encrypt(txtCvv.Text); clientData.PaymentInfo = paymentDataInfo; // add rush shipping level to cart object if (!string.IsNullOrEmpty(ddlAdditionShippingCharge.SelectedValue)) { clientData.CartInfo.ShippingChargeKey = ddlAdditionShippingCharge.SelectedValue; } //Save opt-in value in order clientData.OrderAttributeValues.AddOrUpdateAttributeValue("SpecialOffersOptIn", new CSBusiness.Attributes.AttributeValue(chkOptIn.Checked)); ClientOrderData = clientData; //Set the Client Order objects ClientCartContext contextData = (ClientCartContext)Session["ClientOrderData"]; contextData.CustomerInfo = CustData; ////////contextData.CartAbandonmentId = CSResolve.Resolve<ICustomerService>().InsertCartAbandonment(CustData, contextData); Session["ClientOrderData"] = contextData; //Save Order information before upsale process int orderId = 0; //if (rId == 1) contextData.CartAbandonmentId = CSResolve.Resolve <ICustomerService>().InsertCartAbandonment(CustData, contextData); orderId = CSResolve.Resolve <IOrderService>().SaveOrder(clientData); UserSessions.InsertSessionEntry(Context, true, clientData.CartInfo.Total, clientData.CustomerInfo.CustomerId, orderId); //else //{ // //update order with modified customer shipping and billing and credit card information // orderId = clientData.OrderId; // CSResolve.Resolve<IOrderService>().UpdateOrder(orderId, clientData); //} if (orderId > 1) { clientData.OrderId = orderId; Session["ClientOrderData"] = clientData; //if (rId == 1) // Response.Redirect("PostSale.aspx"); //else //Response.Redirect("Postsale.aspx"); } } }