public void should_simple_synchronous_call_isaddressvalid_with_bad_address_returns_false() { AddressClient client = new AddressClient(); AddressValid result = client.IsAddressValid(Network.Doge, Consts.Wrong); Assert.IsNotNull(result); Assert.IsTrue(result.Status == Consts.Success); Assert.IsTrue(!result.Data.IsValid); }
public void simple_synchronous_call_isaddressvalid_returns_result_with_proxy() { AddressClient client = new AddressClient(); AddressValid result = client.IsAddressValid(Network.Doge, "DM7Yo7YqPtgMsGgphX9RAZFXFhu6Kd6JTT"); Assert.IsNotNull(result); Assert.IsTrue(result.Status == Consts.Success); Assert.IsTrue(result.Data.Address == "DM7Yo7YqPtgMsGgphX9RAZFXFhu6Kd6JTT"); Assert.IsTrue(result.Data.IsValid); }
/// <summary> /// Checks whether the added address is similar to an address already in the database and if not /// store this address in a session variable to be added when the order is completed. /// </summary> private AddressValid GetAddress(bool createTable) { List <AddressManager> similarAddresses = new List <AddressManager>(); List <AddressManager> currentAddresses = AddressManager.GetAddresses(); AddressValid addressSuccess = new AddressValid(); bool addOrder = true; string addressLine1, addressLine2, city, zipOrPostcode, countyStateProvince, country; addressLine1 = addressLine1Txt.Text; addressSuccess.addressLine1 = addressLine1; addressLine2 = addressLine2Txt.Text; addressSuccess.addressLine2 = addressLine2; city = cityTxt.Text; addressSuccess.city = city; zipOrPostcode = zipOrPostcodeTxt.Text; addressSuccess.zipOrPostcode = zipOrPostcode; countyStateProvince = countyStateProvinceTxt.Text; addressSuccess.countyStateProvince = countyStateProvince; country = Variables.GetCountryByCode(Request["countryDdl"]); addressSuccess.country = country; string addeddAddress = addressLine1 + addressLine2 + city + zipOrPostcode + countyStateProvince + country; foreach (AddressManager address in currentAddresses) { int diff = FuzzySearching.LD(addeddAddress, address.GetAddressStrWithoutBreaks()); if (diff == 0) { addressSuccess.existingAddress = address; addOrder = true; } //Only get addresses that have less than 5 characters different else if (diff < 5) { similarAddresses.Add(address); addOrder = false; addressesTbl.Visible = false; similarAddressesTbl.Visible = true; } } if (similarAddresses.Count > 0 && createTable == true) { AddSimilarHeaderRow(); LoadAddresses(similarAddresses); } addressSuccess.addresses = similarAddresses; addressSuccess.addOrder = addOrder; return(addressSuccess); }
public async Task <AddressValid> IsAddressValidAsync(Network network, string address) { AddressValid response = await GetQuery <AddressValid, AddressValid>(string.Format(IsAddressValidUrl, network._network, address)); return(response); }
/// <summary> /// Adds a new address to be used for this order but does not save it to the database until the order is completed /// to prevent unused records from being added. /// </summary> protected void AddOrderBtn_Click(object sender, EventArgs e) { try { string addressLine1, addressLine2, city, zipOrPostcode, countyStateProvince, country; bool addOrder = true; long vehicleAvailableID, locationID, addressID; DateTime hireStart, hireEnd; CustomerManager customer = null; AddressManager address; addressLine1 = addressLine1Txt.Text; addressLine2 = addressLine2Txt.Text; if (Variables.CheckAlphaNumericCharacters(cityTxt.Text) && cityTxt.Text != "") { city = cityTxt.Text; } else { city = ""; addOrder = false; inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a valid city."; } if (Variables.CheckAlphaNumericCharacters(zipOrPostcodeTxt.Text) == true && zipOrPostcodeTxt.Text != "") { zipOrPostcode = zipOrPostcodeTxt.Text; } else { zipOrPostcode = ""; addOrder = false; inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid zip or postcode."; } countyStateProvince = countyStateProvinceTxt.Text; country = Variables.GetCountryByCode(Request["countryDdl"]); if (country == "") { addOrder = false; inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a country."; } AddressValid addressSuccess = GetAddress(false); if (addressSuccess.addOrder == true && addOrder == true) { vehicleAvailableID = Convert.ToInt32(Request.QueryString["VehicleAvailableID"]); locationID = Convert.ToInt32(Request.QueryString["LocationID"]); hireStart = Convert.ToDateTime(Request.QueryString["StartDateTime"]); hireEnd = Convert.ToDateTime(Request.QueryString["EndDateTime"]); //AddressManager.AddNewAddress(1, addressSuccess.addressLine1, addressSuccess.addressLine2, addressSuccess.city // , addressSuccess.zipOrPostcode, addressSuccess.countyStateProvince, addressSuccess.country); if (customersInCompanyDdl.SelectedValue != "") { if (Session["LoggedInType"].ToString() == "Customer") { customer = CustomerManager.GetCustomers().Where(x => x.UserName.Equals(Session["UserName"].ToString(), StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); } else if (Session["LoggedInType"].ToString() == "Company") { CompanyManager company; company = CompanyManager.GetCompanies().Where(x => x.UserName.Equals(Session["UserName"].ToString(), StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); customer = CustomerManager.GetCustomers().Where(x => x.CustomerID.ToString() == customersInCompanyDdl.SelectedValue.Split(',')[0]).SingleOrDefault(); } if (addressSuccess.existingAddress == null) { addressID = AddressManager.GetLastAddedAddress(); address = new AddressManager(addressID + 1, 1, addressSuccess.addressLine1, addressSuccess.addressLine2, addressSuccess.city , addressSuccess.zipOrPostcode, addressSuccess.countyStateProvince, addressSuccess.country); } else { address = addressSuccess.existingAddress; } StoreSessionVariables(address, vehicleAvailableID, locationID, hireStart, hireEnd, customer.CustomerID, false); Response.Redirect("~/ReviewOrder", false); orderCreatedLbl.Text = "Order Created"; } else { inputErrorLbl.Text = "Please select a customer to book for"; } } } catch (Exception ex) { generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator."; } }