/// <summary> /// raised on address edit click /// </summary> private void RaiseEditAddressRequest(Address originalItem) { var item = originalItem.DeepClone(_entityFactory as IKnownSerializationTypes); if (RaiseEditAddressRequest(item, "Edit Address")) { OnUIThread(()=>originalItem.InjectFrom<CloneInjection>(item)); } }
public ActionResult AddressEdit(AddressEditModel model) { if (ModelState.IsValid) { if (model.Address != null) { var u = _userClient.GetCurrentCustomer(false); Organization org = null; if (!String.IsNullOrEmpty(model.OrganizationId)) { org = _userClient.GetOrganizationById(model.OrganizationId); } var parent = org == null ? u : (Member)org; if (model.IsDefaultBilling) { //remove previous default Billing var address = parent.Addresses.FirstOrDefault(x => x.Name.Contains(UserHelper.DefaultBilling)); if (address != null) { address.Name = address.Name.Replace(UserHelper.DefaultBilling, string.Empty); } model.Address.Name += UserHelper.DefaultBilling; } if (model.IsDefaultShipping) { //remove previous default Shipping var address = parent.Addresses.FirstOrDefault(x => x.Name.Contains(UserHelper.DefaultShipping)); if (address != null) { address.Name = address.Name.Replace(UserHelper.DefaultShipping, string.Empty); } model.Address.Name += UserHelper.DefaultShipping; } var exisintgAddress = parent.Addresses.FirstOrDefault(p => p.AddressId.Equals(model.Address.AddressId)); if (exisintgAddress != null) { exisintgAddress.InjectFrom(model.Address); } else { //create new var newAddress = new Address(); newAddress.InjectFrom(model.Address); if (parent.Addresses.Count == 0) { newAddress.Name += String.Format("{0}{1}", UserHelper.DefaultBilling, UserHelper.DefaultShipping); } parent.Addresses.Add(newAddress); } _userClient.SaveCustomerChanges(u.MemberId); } return RedirectToAction(String.IsNullOrEmpty(model.OrganizationId) ? "AddressBook" : "CompanyAddressBook"); } model.Countries = _countryClient.GetAllCountries(); return View(model); }
/// <summary> /// Converts to customer address. /// </summary> /// <param name="address">The address.</param> /// <returns>Address.</returns> private static Address ConvertToCustomerAddress(AddressModel address) { var addr = new Address(); addr.InjectFrom(address); return addr; }
public static Address ConvertToCustomerAddress(OrderAddress address) { var addr = new Address(); addr.InjectFrom(address); return addr; }