private static void WriteAddressDetails(AddressDetail addressDetail) { Console.WriteLine(); Console.WriteLine("Address details:"); Console.WriteLine("Full: {0}", addressDetail.full); Console.WriteLine("Display: {0}", addressDetail.displayline); Console.WriteLine("Line 1: {0}", addressDetail.address1); Console.WriteLine("Line 2: {0}", addressDetail.address2); Console.WriteLine("Line 3: {0}", addressDetail.address3); Console.WriteLine("Line 4: {0}", addressDetail.address4); Console.WriteLine("Type: {0}", addressDetail.type); Console.WriteLine("Unique ID: {0}", addressDetail.id); Console.WriteLine("NZ Post DPID: {0}", addressDetail.dpid); Console.WriteLine("LINZ Street ID: {0}", addressDetail.linzid); Console.WriteLine("Parcel ID: {0}", addressDetail.parcelid); Console.WriteLine("Meshblock ID: {0}", addressDetail.meshblock); Console.WriteLine("Number: {0}", addressDetail.number); Console.WriteLine("Alpha: {0}", addressDetail.alpha); Console.WriteLine("Unit Number: {0}", addressDetail.unitnumber); Console.WriteLine("Unit Type: {0}", addressDetail.unittype); Console.WriteLine("Foor: {0}", addressDetail.floor); Console.WriteLine("Street: {0}", addressDetail.street); Console.WriteLine("Suburb: {0}", addressDetail.suburb); Console.WriteLine("Mailtown: {0}", addressDetail.mailtown); Console.WriteLine("City: {0}", addressDetail.city); Console.WriteLine("Postcode: {0}", addressDetail.postcode); Console.WriteLine("X: {0}", addressDetail.x); Console.WriteLine("Y: {0}", addressDetail.y); Console.WriteLine("Territory: {0}", addressDetail.territory); Console.WriteLine("Region: {0}", addressDetail.region); Console.WriteLine("Building: {0}", addressDetail.building); Console.WriteLine("Box Bag Lobby: {0}", addressDetail.boxbaglobby); Console.WriteLine("Box bag Number: {0}", addressDetail.boxbagnumber); Console.WriteLine("Modified Date: {0}", addressDetail.modified); }
private static string ToCity(this AddressDetail address) { return(address.village ?? address.town ?? address.city_district ?? address.municipality); }
/// <summary> /// Sets a postal address from the google contact into the std contact. /// </summary> /// <param name="stdEntry">The std entry to be updated.</param> /// <param name="address">The address to set.</param> public static void SetAddress(this StdContact stdEntry, StructuredPostalAddress address) { var stdAddress = new AddressDetail(address.FormattedAddress); if (address.Usage == "home") { if (stdEntry.PersonalAddressPrimary == null) { stdEntry.PersonalAddressPrimary = stdAddress; } else { stdEntry.PersonalAddressSecondary = stdAddress; } } if (address.Usage == "Work") { if (stdEntry.BusinessAddressPrimary == null) { stdEntry.BusinessAddressPrimary = stdAddress; } else { stdEntry.BusinessAddressSecondary = stdAddress; } } }
/// <summary> /// retriving index customer Address /// </summary> /// <param name="value"></param> /// <returns></returns> public int IndexOf(object value) { AddressDetail ad = (AddressDetail)value; return(_customerAddressesList.IndexOf(ad)); //return ((IList)_customerAddressesList).IndexOf(value); }
public AddressDetail GetAddressDetails(int un_id) { var address = new AddressDetail(); var cmd = new OracleCommand("tp.PKG_USER_PARAMETERS.get_address_details"); cmd.Parameters.Add("p_un_id", OracleDbType.Int32).Value = un_id; cmd.Parameters.Add("p_result_curs", OracleDbType.RefCursor, ParameterDirection.Output); cmd.CommandType = CommandType.StoredProcedure; string error; new OracleDb <PKG_USER_PARAMETERS>().ProcessEachRow(cmd, out error, delegate(OracleDataReader reader) { address.RegionId = reader["region_id"].ToString(); address.DistrictId = reader["district_id"].ToString(); address.StreetId = reader["street_id"].ToString(); address.StreetText = reader["street_text"].ToString(); address.PlaceNumber = reader["place_number"].ToString(); }); if (!string.IsNullOrEmpty(error)) { throw new Exception(error); } return(address); }
/// <summary> /// Adds a specific <see cref="AddressDetail"/> to the google address list of a google contact /// </summary> /// <param name="googleContact">The google contact.</param> /// <param name="stdAddress">The <see cref="AddressDetail"/> data from the <see cref="StdContact"/>.</param> /// <param name="addressType">A text type of address ("home", "work").</param> public static void AddAddress(this Contact googleContact, AddressDetail stdAddress, string addressType) { if (stdAddress == null) { return; } var addressText = stdAddress.ToString(AddressFormatting.StreetAndCity); if (!string.IsNullOrEmpty(addressText)) { var postalAddress = new StructuredPostalAddress { Street = stdAddress.StreetName, City = stdAddress.CityName, Rel = GoogleSchemaPrefix2005 + addressType, }; if (!IsAddressExisting(googleContact.PostalAddresses, stdAddress)) { googleContact.PostalAddresses.Add(postalAddress); } } googleContact.AddPhoneNumber(stdAddress.Phone, addressType); }
public async Task <IActionResult> Put(long id, AddressDetail address) { if (id != address.Id) { return(BadRequest()); } //todo: normally if valid you would do an update to your data store, in this case well'll just drop and add - once again it doesn't matter var addressInDb = getSourceData().Where(a => a.Id == id).FirstOrDefault(); if (addressInDb == null) { return(NotFound()); } var addr = getSourceData().Find(a => a.Id == id); //simulation, would be normally be a datastore like above if (addr != null) { getSourceData().Remove(addr); } var addresses = getSourceData(); addresses.Add(address); return(NoContent()); //or you could return CreatedAtAction(nameof(GetAddress), new { id = addressDetail.Id }, addressDetail); but NoContent is more RESTy }
public IList <AddressDetail> FindAddress(AddressDetail Address, int type, string dbName) { if (!String.IsNullOrEmpty(Address.AddressNbr.ToString())) { return(findAddress.FindAddressNbr(Address.AddressNbr.ToString(), type, "spFindAddressNbr", dbName)); } else if (!String.IsNullOrEmpty(Address.Name)) { return(findAddress.FindAddressNbr(Address.Name.ToString(), type, "spFindAddressName", dbName)); } else if (!String.IsNullOrEmpty(Address.Street)) { return(findAddress.FindAddressNbr(Address.Street.ToString(), type, "spFindAddressStreet", dbName)); } else if (!String.IsNullOrEmpty(Address.Zipcode.ToString())) { return(findAddress.FindAddressNbr(Address.Zipcode.ToString(), type, "spFindAddressZipCode", dbName)); } else if (!String.IsNullOrEmpty(Address.Zipsuffix.ToString())) { return(findAddress.FindAddressNbr(Address.Zipsuffix.ToString(), type, "spFindAddressZipSuffix", dbName)); } else if (!string.IsNullOrEmpty(Address.City)) { return(findAddress.FindAddressNbr(Address.City.ToString(), type, "spFindAddressCity", dbName)); } else if (!String.IsNullOrEmpty(Address.Remark)) { return(findAddress.FindAddressNbr(Address.Remark.ToString(), type, "spFindAddressRemark", dbName)); } else { } return(null); }
/// <summary> /// Removing Particular Address Od A Customer /// </summary> /// <param name="ad"></param> /// <param name="Id"></param> public void RemoveAddress(AddressDetail ad) { try { dll.RemoveAddress(ad); } catch (AddressException aa) when(aa.Message == "Dear Customer You dont Have this address any more you no need to delete") { } }
public async Task <IHttpActionResult> AssignJob([FromBody] AsssignJobRequest request) { try { var pickUp = new AddressDetail(request.PickupAddress); var delivery = new AddressDetail(request.DeliveryAddress); var newJob = new TransportRequest(pickUp, delivery) { DeliveryDate = DateTime.Now, PreferredDeliveryTime = StaticTransportRequest.DeliveryTime.Morning }; var response = await _transportManagementService.AddTransportRequest(newJob); if (response.IsValid == false) { return(Ok(new ApiBadRequestResponse(400, response.Errors))); } return(Ok(new ApiOkResponse(response.Object, response.Object != null ? 1 : 0))); } catch (Exception ex) { //Log here return(BadRequest()); } }
public ActionResult Address() { AddressDetail objAddressDetail = new AddressDetail(); GetDropDownAddress(objAddressDetail); GetUserDataAddress(objAddressDetail); return(View("~/Views/Profile/Address.cshtml", objAddressDetail)); }
public async Task <ActionResult <AddressDetail> > Post(AddressDetail addressDetail) { //todo: I would validate the entity being passed, if failed log and error and return a 500 to requesting client //If validate do something with the object, likely a database insert being a post //I could add this the collection but being stateless it wouldn't matter. The CreatedAtAction would normally //pull back the objective I just created, in this case it points to an item that doesn't exist. return(CreatedAtAction(nameof(Get), new { id = addressDetail.Id }, addressDetail)); }
/// <summary> /// Returning Particular Address Of a Customer /// </summary> /// <param name="ad"></param> /// <param name="Id"></param> /// <returns></returns> public AddressDetail ReturnAddress(AddressDetail ad) { AddressDetail ReturnedAddress = null; try { ReturnedAddress = dll.ReturnAddress(ad); } catch (AddressException ae) when(ae.Message == "Requested Address Not Found") { } return(ReturnedAddress); }
public ActionResult Address(AddressDetail objAddressDetail) { GetDropDownAddress(objAddressDetail); if (!ModelState.IsValid) { return(View(objAddressDetail)); } objAddressDetail.AddEditAddress(objAddressDetail, clsCommon.Update); return(View(objAddressDetail)); }
public void RemoveAllAddresses(AddressDetail ad) { try { dll.RemoveAllAddresses(ad); } catch (AddressException ae) when(ae.Message == "Dear Customer No addresses For you") { } }
/// <summary> /// Adding new Customer Address /// </summary> /// <param name="address">Attribute to add adddress in to collection</param> public int Add(object value) { AddressDetail address = (AddressDetail)value; _customerAddressesList.Add(address); _jsonAddresses = JsonConvert.SerializeObject(_customerAddressesList); streamWriter.Write(_jsonAddresses); streamWriter.Close(); return(_customerAddressesList.Count - 1); }
public void Remove(object value) { AddressDetail ad = (AddressDetail)value; _customerAddressesList.Remove(ad); _jsonAddresses = JsonConvert.SerializeObject(_customerAddressesList); streamWriter.Write(_jsonAddresses); streamWriter.Close(); //((IList)_customerAddressesList).Remove(value); }
public void Insert(int index, object value) { AddressDetail ad = (AddressDetail)value; _customerAddressesList.Insert(index, ad); _jsonAddresses = JsonConvert.SerializeObject(_customerAddressesList); streamWriter.Write(_jsonAddresses); streamWriter.Close(); //((IList)_customerAddressesList).Insert(index, value); }
/// <summary> /// Removing Customer All Addresses /// </summary> static void RemoveMyAddresses() { AddressDetail ad = new AddressDetail(); AddressBusinessLogic ab = new AddressBusinessLogic(); try { ab.RemoveAllAddresses(ad); } catch (AddressException ae) { throw new AddressException("For you there were no Adderesses"); } }
private static string FormatStreet(AddressDetail a) { StringBuilder sb = new StringBuilder(); if (!String.IsNullOrEmpty(a.Unit)) { sb.Append(a.Unit); sb.Append("-"); } sb.Append(a.Street); return(sb.ToString()); }
/// <summary> /// Formats the address according to the specified format string. /// </summary> /// <remarks> /// Valid format specifiers are as follows: /// %S - street address, including number and unit/apartment number /// %V - city /// %P - Province /// %Z - Postal/Zip Code /// %C - country /// </remarks> /// <param name="pn"></param> /// <param name="format"></param> /// <returns></returns> public static string Format(AddressDetail a, string format) { string result = format; result = result.Replace("%S", a.Street == null ? "" : FormatStreet(a)); result = result.Replace("%V", a.City == null ? "" : a.City); result = result.Replace("%P", a.Province == null ? "" : a.Province); result = result.Replace("%Z", a.PostalCode == null ? "" : a.PostalCode); result = result.Replace("%C", a.Country == null ? "" : a.Country); return(result.Trim()); }
/// <summary> /// checking enteres state was in list or not /// </summary> /// <param name="ad"></param> public void ValidatingState(AddressDetail ad) { TextInfo CountryText = new CultureInfo("en-US", false).TextInfo; ad.CustomerCountry = CountryText.ToTitleCase(ad.CustomerCountry); var b = StatesList.Contains(ad.State); if (b != true) { throw new AddressException("Enteres State was not valid please check once"); } }
/// <summary> /// The check constructor country. /// </summary> /// <param name="checkThis"> /// The check this. /// </param> /// <param name="countryName"> /// The country name. /// </param> private static void CheckConstructorCountry(string checkThis, string countryName) { var address = new AddressDetail(checkThis); if (string.IsNullOrEmpty(countryName)) { Assert.IsTrue(string.IsNullOrEmpty(address.CountryName)); } else { Assert.AreEqual(countryName, address.CountryName); } }
/// <summary> /// Retunrning Default Address /// </summary> /// <param name="ad">Customer Address Object</param> /// <returns></returns> public AddressDetail RetunDefaultAddress(AddressDetail ad) { AddressDetail DeafultAddress = null; try { DeafultAddress = dll.RetunDefaultAddress(ad); } catch (AddressException ae) when(ae.Message == "No default Address you Might not enteres your address while singup") { } return(DeafultAddress); }
/// <summary> /// Return data in one long String /// </summary> /// <returns></returns> public string SummAllData() { StringBuilder sb = new StringBuilder(""); sb.Append(Title); sb.Append(FirstName); sb.Append(MiddleName); sb.Append(LastName); sb.Append(Suffix); #if (!ANNIVESARY_NOT_WORK) sb.Append(Anniversary.ToString("yyyyMMdd")); #endif sb.Append(Birthday.ToString("yyyyMMdd")); sb.Append(Notes); sb.Append(IM); ///TODO: How control image change in MD5 hash sb.Append(string.IsNullOrEmpty(ImagePath)); //sb.Append(ImageHash); foreach (Constants.PhoneType t in Enum.GetValues(typeof(Constants.PhoneType))) { sb.Append(GetRightPhoneNumber(t)); } foreach (Constants.AddressType t in Enum.GetValues(typeof(Constants.AddressType))) { AddressDetail ad = GetRightAddress(t); if (ad != null) { sb.Append(ad.Street); sb.Append(ad.State); sb.Append(ad.PostalCode); sb.Append(ad.POBox); sb.Append(ad.CountryRegion); sb.Append(ad.City); sb.Append(Enum.GetName(typeof(Constants.AddressType), ad.Type)); } } sb.Append(email1); sb.Append(email2); sb.Append(email3); sb.Append(Company); sb.Append(Department); sb.Append(JobTitle); sb.Append(WebServer); foreach (string cat in Category) { sb.Append(cat); } return(sb.ToString().Replace("\r", "").Replace("\n", "")); }
public static AddressDetailDAO MapToAddressDetailDAO(AddressDetail addressDetail) { var ad = new AddressDetailDAO(); ad.Id = addressDetail.AddressID; ad.Address1 = addressDetail.Address1; ad.Address2 = addressDetail.Address2; ad.City = addressDetail.CityName; ad.State = addressDetail.StateName; ad.Zipcode = addressDetail.Zipcode; ad.Active = addressDetail.Active; return(ad); }
public static AddressDetail MapToAddressDetail(AddressDetailDAO addressDetail) { var ad = new AddressDetail(); ad.AddressID = addressDetail.Id; ad.Address1 = addressDetail.Address1; ad.Address2 = addressDetail.Address2; ad.CityName = addressDetail.City; ad.StateName = addressDetail.State; ad.Zipcode = addressDetail.Zipcode; ad.Active = addressDetail.Active; return(ad); }
public string AddCustomerOrderAddress([FromBody] AddCustomerOrderAddressRequestModel requestModel) { var customer = Context.Customers.Include(c => c.Addresses).First(c => c.CustomerId == requestModel.CustomerId); var order = Context.Orders.First(o => o.OrderId == requestModel.OrderId); if (requestModel.AddressDetailId == 0) { var newAddressDetail = new AddressDetail { AddressType = requestModel.AddressType, AddressLine1 = requestModel.AddressLine1, AddressLine2 = requestModel.AddressLine2, City = requestModel.City, Country = requestModel.Country, PostalCode = requestModel.PostalCode, CreateDate = DateTime.Now, CreateUser = requestModel.Username }; customer.Addresses.Add(newAddressDetail); Context.SaveChanges(); order.AddressDetailId = newAddressDetail.AddressDetailId; order.UpdateDate = DateTime.Now; order.UpdateUser = requestModel.Username; Context.SaveChanges(); } else { var address = customer.Addresses.First(a => a.AddressDetailId == requestModel.AddressDetailId); address.AddressType = requestModel.AddressType; address.AddressLine1 = requestModel.AddressLine1; address.AddressLine2 = requestModel.AddressLine2; address.City = requestModel.City; address.Country = requestModel.Country; address.PostalCode = requestModel.PostalCode; address.UpdateDate = DateTime.Now; address.UpdateUser = requestModel.Username; order.AddressDetailId = address.AddressDetailId; order.UpdateDate = DateTime.Now; order.UpdateUser = requestModel.Username; Context.SaveChanges(); } return("Success"); }
/// <summary> /// Validating Address and Calling Data Layer Method /// </summary> /// <param name="address"></param> public void AddAddress(AddressDetail address) { var b = CountriesList.Contains(address.CustomerCountry); if (b == true) { if (StatesList.Contains(address.State)) { string[] PhoneNumber = address.MobileNumber.Split(' '); if (PhoneNumber[0].Length == 2 && PhoneNumber[1].Length == 10) { string[] NumberCode = PhoneNumber[0].Split('+'); if (NumberCodes.Contains(NumberCode[1])) { string Number = PhoneNumber[1].ToString(); if (Number.All(char.IsDigit)) { if (dll.CustomerAddressList.Contains(address)) { AddressDetail samp = dll.CustomerAddressList.Find(temp => temp.CustomerId == address.CustomerId); address.AddressId = samp.AddressId + 1; dll.Add(address); } else { dll.Add(address); } } else { throw new AddressException("Enter only digits"); } } else { throw new AddressException("The enteres Number code doent belongs to any country please check once"); } } } else { throw new AddressException("Enter Valid State"); } } else { throw new AddressException("Enteres Country was not valid please check once"); } }
public ActionResult GetAddressDetails(AddressDetail Address)//, FormCollection collection,string Language { try { int type = Address.CustomerType; string databaseName = HttpContext.Session.GetString("Database_Name"); IList <AddressDetail> addressDetails = _address.FindAddress(Address, type, databaseName); return(Json(addressDetails)); } catch (Exception ex) { return(Json(ex.Message)); } }
public static AddressDetail Map(AddressDetail entity, RegistrationViewModel viewModel) { return Mapper.Map(viewModel, entity); }