コード例 #1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            strErrorMessage = "";
            intVaidError = 0;
            CheckValidation();

            if (intVaidError == 0)
            {
                ServeAtDoorstepData.VendorDetails objVenDetails = new ServeAtDoorstepData.VendorDetails();
                objVenDetails.LoginName = txtLoginname.Value.ToString();
                objVenDetails.LoginPassword = txtPassword.Value.ToString();
                objVenDetails.VendorID = 0;
                objVenDetails.VendorName = txtVendorName.Value.ToString();
                objVenDetails.VendorAddress = txtAddress.Value.ToString();
                objVenDetails.VendorStreet = txtStreet.Value.ToString();
                objVenDetails.VendorCityId = Convert.ToInt32(ddlCity.SelectedItem.Value.ToString());
                objVenDetails.VendorStateId = Convert.ToInt32(ddlState.SelectedItem.Value.ToString());
                objVenDetails.VendorCountryId = Convert.ToInt32(ddlCountry.Value.ToString());
                objVenDetails.VendorEmail = txtEmail.Value.ToString();
                objVenDetails.VendorZipcode = txtZipcode.Value.ToString();
                objVenDetails.VendorMobile = txtMobileNo.Value.ToString();
                objVenDetails.VendorBusinessPhone = txtBusinessNo.Value.ToString();
                objVenDetails.CompanyName = txtCompanyName.Value.ToString();
                objVenDetails.OwnerName = txtOwnerName.Value.ToString();
                objVenDetails.ContactName = txtContactName.Value.ToString();
                objVenDetails.ContactNumber = txtContactNo.Value.ToString();
                objVenDetails.CategoryId = 0;// Convert.ToInt32(ddlCategory.Value.ToString());
                objVenDetails.CoverageArea = txtCoverageArea.Value.ToString();
                objVenDetails.WebsiteUrl = txtWebsiteUrl.Value.ToString();
                objVenDetails.GeoCode = "0";//.Value.ToString();
                objVenDetails.MemberShipId = Convert.ToInt32(ddlMembership.Value.ToString());
                objVenDetails.CreditCardNumber = txtCredCardNo.Value.ToString();
                objVenDetails.CreditCardType = txtCredCardType.Value.ToString();
                objVenDetails.CreditCardExpired = txtExpiredDate.Value.ToString();
                objVenDetails.CVCNumber = txtCVC.Value.ToString();

                objService = new ServeAtDoorstepService();
                int intVendId = objService.AddVendorRegister(objVenDetails);

                for(int intCnt=0;intCnt<chkCateList.Items.Count;intCnt++)
                {
                    if (chkCateList.Items[intCnt].Selected == true)
                    {
                        int iCatID = Convert.ToInt32(chkCateList.Items[intCnt].Value.ToString());

                        objService = new ServeAtDoorstepService();
                        DataTable dtServ = objService.SelectServiceByCatID(iCatID);

                        //if (dtServ.Rows.Count > 0)
                        {
                            //for (int intSer = 0; intSer < dtServ.Rows.Count; intSer++)
                            {
                                VendorServiceDetails objVSData = new VendorServiceDetails();
                                objVSData.VendorServiceId = 0;
                                objVSData.VendorId = intVendId;
                                objVSData.CategoryId = iCatID;
                                objVSData.ServiceId = 0;// Convert.ToInt32(dtServ.Rows[0]["ServiceID"].ToString());
                                objVSData.Status = "1";

                                int i = objService.AddVendorService(objVSData);

                            }
                        }
                    }
                }

                #region .. VENDOR COVERAGE AREA ..

                //var requestUri = "https://www.zipwise.com/webservices/radius.php?key=yj7b6stzbr3lmmoo&zip=" + txtZipcode.Value.Trim() + "&radius=5&format=xml";
                //var requestUri = "https://zipcodedistanceapi.redline13.com/rest/VGO5Fus2poaNqECnpYc77kfZARW0TjgP04UFymHYLSMcxoAWnM3u6itHaqH4KXTK/radius.xml/" + txtZipcode.Value.Trim() + "/15/mile";
                var requestUri = "https://zipcodedistanceapi.redline13.com/rest/dtMOhbP1itLs2K2WQNccHRkUoEGJfDds7Zgoa6ptAbWCWYzMMLYuDjo1Y4LdIYGP/radius.xml/" + txtZipcode.Value.Trim() + "/15/mile";

                var webRequest = (HttpWebRequest)WebRequest.Create(requestUri);

                webRequest.Method = "GET";

                webRequest.ContentType = "application/xml";

                HttpWebResponse response;

                string responseContent = "";

                try
                {

                    response = (HttpWebResponse)webRequest.GetResponse();

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(response.GetResponseStream());

                    //Create namespace manager
                    int intAreaCount = 0;
                    string[] sCity = new string[500];
                    string[] state = new string[500];
                    string[] sZip = new string[500];
                    string[] sDis = new string[500];

                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                    nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1");
                    string s = xmlDoc.InnerXml.Contains("error").ToString();
                    if (xmlDoc.InnerXml.Contains("error").ToString() == "False")
                    {
                        XmlNodeList locationElements = xmlDoc.SelectNodes("results/result", nsmgr);
                        int i = 0;
                        foreach (XmlNode location in locationElements)
                        {
                            sZip[i] = location.SelectSingleNode("zip", nsmgr).InnerText;
                            //sCity[i] = location.SelectSingleNode("city", nsmgr).InnerText;
                            //state[i] = location.SelectSingleNode("state", nsmgr).InnerText;
                            //sDis[i] = location.SelectSingleNode("distance", nsmgr).InnerText;

                            i++;
                            intAreaCount++;
                        }
                    }
                    webRequest.Abort();

                    for (int iACnt = 0; iACnt < intAreaCount; iACnt++)
                    {
                        ServeAtDoorstepData.VendorAreaDetails objVendorArea = new VendorAreaDetails();
                        objVendorArea.VendorAreaID = 0;
                        objVendorArea.VendorId = intVendId;
                        objVendorArea.VAZipcode = sZip[iACnt];
                        objVendorArea.VACityName = "";// sCity[iACnt];
                        objVendorArea.VAState = "";//state[iACnt];
                        objVendorArea.VADistance = "";//sDis[iACnt];

                        int j = objService.AddVendorArea(objVendorArea);

                    }
                }
                catch (WebException webex)
                {
                    //lblResult.Text = "INVALID ZIPCODE";

                }

                #endregion

                SendMailtoUser(intVendId);

                lblEmailId.Text = txtEmail.Value.ToString();
                this.ModalPopupSuccess.Show();
                //Response.Redirect("Success.aspx?type=ven");
            }
            else
            {
                divErrorMessage.InnerHtml = strErrorMessage;

            }
        }