/// <summary> /// Returns customer details /// </summary> /// <returns></returns> private static CustomerDTO GetCustomer() { try { var settingKeyValue = DIContainer.Resolve <IKenticoResourceService>().GetSettingsKey("KDA_SoldToGeneralInventory"); var distributorID = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)); var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault(); var customer = CustomerInfoProvider.GetCustomerInfo(distributorAddress.AddressCustomerID); return(new CustomerDTO { FirstName = customer.CustomerFirstName, LastName = customer.CustomerLastName, KenticoCustomerID = customer.CustomerID, Email = customer.CustomerEmail, CustomerNumber = settingKeyValue, KenticoUserID = customer.CustomerUserID, Phone = customer.CustomerPhone }); } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetCustomer", ex.Message); return(null); } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (customerObj == null) { return; } if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); } if (customerId != 0) { string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine") .NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity") .NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode") .NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result; // Check country presence if (errorMessage == "" && (ucCountrySelector.CountryID <= 0)) { errorMessage = GetString("countryselector.selectedcountryerr"); } if (errorMessage == "") { // Get object AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId); if (addressObj == null) { addressObj = new AddressInfo(); } addressObj.AddressIsBilling = chkAddressIsBilling.Checked; addressObj.AddressIsShipping = chkAddressIsShipping.Checked; addressObj.AddressZip = txtAddressZip.Text.Trim(); addressObj.AddressPhone = txtAddressDeliveryPhone.Text.Trim(); addressObj.AddressPersonalName = txtPersonalName.Text.Trim(); addressObj.AddressLine1 = txtAddressLine1.Text.Trim(); addressObj.AddressEnabled = chkAddressEnabled.Checked; addressObj.AddressLine2 = txtAddressLine2.Text.Trim(); addressObj.AddressCity = txtAddressCity.Text.Trim(); addressObj.AddressCountryID = ucCountrySelector.CountryID; addressObj.AddressStateID = ucCountrySelector.StateID; addressObj.AddressIsCompany = chkAddressIsCompany.Checked; addressObj.AddressName = AddressInfoProvider.GetAddressName(addressObj); addressObj.AddressCustomerID = customerId; AddressInfoProvider.SetAddressInfo(addressObj); URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(addressObj.AddressID) + "&saved=1"); } else { lblError.Visible = true; lblError.Text = errorMessage; } } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(actionArgument)); } else if (actionName == "delete") { if (customerObj == null) { return; } if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); } int addressId = ValidationHelper.GetInteger(actionArgument, 0); // Check for the address dependences if (AddressInfoProvider.CheckDependencies(addressId)) { lblError.Visible = true; lblError.Text = GetString("Ecommerce.DeleteDisabled"); return; } // Delete AddressInfo object from database AddressInfoProvider.DeleteAddressInfo(addressId); } }
private AddressInfo GetLastUsedAddress() { return(AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID) .OrderByDescending("AddressLastModified") .TopN(1) .FirstOrDefault()); }
public void SaveShippingAddress(DeliveryAddress address) { var customer = ECommerceContext.CurrentCustomer; var info = new AddressInfo { AddressID = address.Id, AddressLine1 = address.Address1, AddressLine2 = address.Address2, AddressCity = address.City, AddressStateID = address.State.Id, AddressCountryID = address.Country.Id, AddressZip = address.Zip, AddressCustomerID = customer.CustomerID, AddressPersonalName = $"{customer.CustomerFirstName} {customer.CustomerLastName}", AddressPhone = address.Phone }; info.AddressName = $"{info.AddressPersonalName}, {info.AddressLine1}, {info.AddressCity}"; info.SetValue("AddressType", AddressType.Shipping.Code); info.SetValue("CompanyName", address.CustomerName); info.SetValue("Email", address.Email); AddressInfoProvider.SetAddressInfo(info); address.Id = info.AddressID; }
/// <summary> /// Create Shopping cart with item by customer /// </summary> /// <param name="customerAddressID"></param> /// <param name="txtQty"></param> private void CreateShoppingCartByCustomer(SKUInfo product, int customerAddressID, int productQty, double skuPrice) { try { var customerAddress = AddressInfoProvider.GetAddressInfo(customerAddressID); if (!DataHelper.DataSourceIsEmpty(product)) { ShoppingCartInfo cart = new ShoppingCartInfo(); cart.ShoppingCartSiteID = CurrentSite.SiteID; cart.ShoppingCartCustomerID = customerAddressID; cart.ShoppingCartCurrencyID = CurrencyInfoProvider.GetMainCurrency(CurrentSite.SiteID).CurrencyID; cart.SetValue("ShoppingCartCampaignID", ProductCampaignID); cart.SetValue("ShoppingCartProgramID", ProductProgramID); cart.SetValue("ShoppingCartDistributorID", customerAddressID); cart.SetValue("ShoppingCartInventoryType", ProductType); cart.User = CurrentUser; cart.ShoppingCartShippingAddress = customerAddress; cart.ShoppingCartShippingOptionID = ProductShippingID; ShoppingCartInfoProvider.SetShoppingCartInfo(cart); ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID, productQty); parameters.CustomParameters.Add("CartItemCustomerID", customerAddressID); ShoppingCartItemInfo cartItem = cart.SetShoppingCartItem(parameters); cartItem.SetValue("CartItemPrice", skuPrice); cartItem.SetValue("CartItemDistributorID", customerAddressID); cartItem.SetValue("CartItemCampaignID", ProductCampaignID); cartItem.SetValue("CartItemProgramID", ProductProgramID); ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem); cart.InvalidateCalculations(); } } catch (Exception ex) { EventLogProvider.LogException("CustomerCartOperations.ascx.cs", "CreateShoppingCartByCustomer()", ex); } }
private AddressInfo GetLastUsedAddress() { ObjectQuery <AddressInfo> lastAddress = null; switch (AddressType) { case BILLING: // Get last modified billing addresses lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, true, false, false, true).TopN(1).OrderByDescending("AddressLastModified"); break; case SHIPPING: lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, false, true, false, true).TopN(1).OrderByDescending("AddressLastModified"); break; case COMPANY: lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, false, false, true, true).TopN(1).OrderByDescending("AddressLastModified"); break; } // Load last used address if there is one if (!DataHelper.DataSourceIsEmpty(lastAddress)) { return(lastAddress.FirstObject); } return(null); }
/// <summary> /// Gets target shipping address /// </summary> /// <returns></returns> private static AddressDTO GetBillingAddress() { try { var distributorID = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)); var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault(); var country = CountryInfoProvider.GetCountries().WhereEquals("CountryID", distributorAddress.GetStringValue("AddressCountryID", string.Empty)).FirstOrDefault(); var state = StateInfoProvider.GetStates().WhereEquals("StateID", distributorAddress.GetStringValue("AddressStateID", string.Empty)).FirstOrDefault(); return(new AddressDTO() { KenticoAddressID = distributorAddress.AddressID, AddressLine1 = distributorAddress.AddressLine1, AddressLine2 = distributorAddress.AddressLine2, City = distributorAddress.AddressCity, State = state.StateCode, Zip = distributorAddress.GetStringValue("AddressZip", string.Empty), KenticoCountryID = distributorAddress.AddressCountryID, Country = country.CountryName, isoCountryCode = country.CountryTwoLetterCode, KenticoStateID = distributorAddress.AddressStateID, AddressPersonalName = distributorAddress.AddressPersonalName, AddressCompanyName = distributorAddress.GetStringValue("CompanyName", string.Empty) }); } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetBillingAddress", ex.Message); return(null); } }
private void InitializeAddress() { if (Customer == null) { return; } var addresses = AddressInfoProvider.GetAddresses(Customer.CustomerID).ToArray(); foreach (AddressInfo addr in addresses) { if (!this.IsPostBack) { var li = new ListItem(addr.AddressID.ToString()); li.Value = addr.AddressID.ToString(); this.hiddenAddressesList.Items.Add(li); li.Selected = CurrentCartAddress != null ? CurrentCartAddress.AddressID == addr.AddressID : addresses.FirstOrDefault().Equals(addr); } var transformation = TransformationInfoProvider.GetTransformation("kda.checkoutpage.ShippingAddress"); var resolver = MacroResolver.GetInstance(); resolver.SetNamedSourceData("ShippingAddress", addr); resolver.SetNamedSourceData("StateCode", addr.GetStateCode()); resolver.SetNamedSourceData("Checked", (CurrentCartAddress != null ? CurrentCartAddress.AddressID == addr.AddressID : addresses.FirstOrDefault().Equals(addr)) ? "checked":""); htmlContent.Text += resolver.ResolveMacros(transformation.TransformationCode); } }
public JsonResult CustomerAddress(int addressID) { // Gets the address with its ID AddressInfo address = AddressInfoProvider.GetAddressInfo(addressID); // Checks whether the address was retrieved if (address == null) { return(null); } // Creates a response with all address information var responseModel = new { Line1 = address.AddressLine1, Line2 = address.AddressLine2, City = address.AddressCity, PostalCode = address.AddressZip, CountryID = address.AddressCountryID, StateID = address.AddressStateID, PersonalName = address.AddressPersonalName }; // Returns serialized information of the address return(Json(responseModel)); }
/// <summary> /// Gets target shipping address /// </summary> /// <returns></returns> private static AddressDto GetTargetAddress() { try { var distributorID = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)); var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault(); var addressLines = new[] { distributorAddress.GetStringValue("AddressLine1", string.Empty), distributorAddress.GetStringValue("AddressLine2", string.Empty) }.Where(a => !string.IsNullOrWhiteSpace(a)).ToList(); var country = CountryInfoProvider.GetCountries().WhereEquals("CountryID", distributorAddress.GetStringValue("AddressCountryID", string.Empty)) .Column("CountryTwoLetterCode").FirstOrDefault(); var state = StateInfoProvider.GetStates().WhereEquals("StateID", distributorAddress.GetStringValue("AddressStateID", string.Empty)).Column("StateCode").FirstOrDefault(); return(new AddressDto() { City = distributorAddress.GetStringValue("AddressCity", string.Empty), Country = country?.CountryTwoLetterCode, Postal = distributorAddress.GetStringValue("AddressZip", string.Empty), State = state?.StateCode, StreetLines = addressLines }); } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetTargetAddress", ex.Message); return(null); } }
/// <summary> /// Binds address object from controls /// </summary> /// <param name="customerID"></param> /// <returns> AddressInfo object</returns> private AddressInfo BindAddressObject(int customerID) { try { int itemID = Request.QueryString["id"] != null?ValidationHelper.GetInteger(Request.QueryString["id"], default(int)) : default(int); if (itemID != default(int)) { var customerData = IsUserCustomer(CurrentUser.UserID); if (!DataHelper.DataSourceIsEmpty(customerData)) { var addressData = AddressInfoProvider.GetAddressInfo(itemID); if (!DataHelper.DataSourceIsEmpty(addressData)) { addressData.AddressLine1 = ValidationHelper.GetString(txtAddressLine1.Text.Trim(), string.Empty); addressData.AddressLine2 = ValidationHelper.GetString(txtAddressLine2.Text.Trim(), string.Empty); addressData.AddressCity = ValidationHelper.GetString(txtCity.Text.Trim(), string.Empty); addressData.AddressZip = ValidationHelper.GetString(txtZipcode.Text.Trim(), string.Empty); addressData.AddressName = string.Format("{0}{1}{2}", !string.IsNullOrEmpty(addressData.AddressLine1) ? addressData.AddressLine1 + "," : addressData.AddressLine1, !string.IsNullOrEmpty(addressData.AddressLine2) ? addressData.AddressLine2 + "," : addressData.AddressLine2, addressData.AddressCity); addressData.AddressPhone = ValidationHelper.GetString(txtTelephone.Text.Trim(), string.Empty); addressData.AddressPersonalName = ValidationHelper.GetString(txtName.Text.Trim(), string.Empty); addressData.AddressCountryID = ValidationHelper.GetInteger(uniSelectorCountry.Value, 0); addressData.AddressStateID = ValidationHelper.GetInteger(uniSelectorState.Value, 0); addressData.SetValue("AddressType", ddlAddressType.ValueDisplayName); addressData.SetValue("Email", txtEmail.Text.Trim()); addressData.SetValue("CompanyName", txtComapnyName.Text.Trim()); addressData.SetValue("AddressTypeID", ddlAddressType.Value); addressData.SetValue("Status", ddlStatus.SelectedValue); return(addressData); } } } else { AddressInfo objAddress = new AddressInfo(); objAddress.AddressLine1 = ValidationHelper.GetString(txtAddressLine1.Text.Trim(), string.Empty); objAddress.AddressLine2 = ValidationHelper.GetString(txtAddressLine2.Text.Trim(), string.Empty); objAddress.AddressCity = ValidationHelper.GetString(txtCity.Text.Trim(), string.Empty); objAddress.AddressZip = ValidationHelper.GetString(txtZipcode.Text.Trim(), string.Empty); objAddress.AddressCustomerID = customerID; objAddress.AddressName = string.Format("{0}{1}{2}", !string.IsNullOrEmpty(objAddress.AddressLine1) ? objAddress.AddressLine1 + "," : objAddress.AddressLine1, !string.IsNullOrEmpty(objAddress.AddressLine2) ? objAddress.AddressLine2 + "," : objAddress.AddressLine2, objAddress.AddressCity); objAddress.AddressPhone = ValidationHelper.GetString(txtTelephone.Text.Trim(), string.Empty); objAddress.AddressPersonalName = ValidationHelper.GetString(txtName.Text.Trim(), string.Empty); objAddress.AddressCountryID = ValidationHelper.GetInteger(uniSelectorCountry.Value, 0); objAddress.AddressStateID = ValidationHelper.GetInteger(uniSelectorState.Value, 0); objAddress.SetValue("AddressType", ddlAddressType.ValueDisplayName); objAddress.SetValue("Email", txtEmail.Text.Trim()); objAddress.SetValue("CompanyName", txtComapnyName.Text.Trim()); objAddress.SetValue("AddressTypeID", ddlAddressType.Value); objAddress.SetValue("Status", ddlStatus.SelectedValue); return(objAddress); } } catch (Exception ex) { EventLogProvider.LogException("CreateAddress.ascx.cs", "BindAddressObject()", ex); } return(null); }
/// <summary> /// Binds the address data to controls /// </summary> /// <param name="itemID">item id of the address data</param> private void BindAddressData(int itemID) { try { AddressInfo addressData = AddressInfoProvider.GetAddresses() .WhereEquals("AddressID", itemID) .FirstOrDefault(); if (!DataHelper.DataSourceIsEmpty(addressData)) { txtAddressLine1.Text = addressData.AddressLine1; txtAddressLine2.Text = addressData.AddressLine2; txtCity.Text = addressData.AddressCity; txtZipcode.Text = addressData.AddressZip; txtName.Text = addressData.AddressPersonalName; txtTelephone.Text = addressData.AddressPhone; uniSelectorCountry.Value = addressData.AddressCountryID; uniSelectorState.Value = addressData.AddressStateID; txtEmail.Text = addressData.GetStringValue("Email", string.Empty); txtComapnyName.Text = addressData.GetStringValue("CompanyName", string.Empty); ddlAddressType.Value = addressData.GetStringValue("AddressTypeID", string.Empty); if (addressData.AddressStateID <= 0) { uniSelectorState.Enabled = false; } } } catch (Exception ex) { EventLogProvider.LogException("CreateAddress.ascx.cs", "BindAddressData()", ex); } }
protected void CreateCustomerAddress(int customerID, UserDto userDto) { var country = FindCountry(userDto.Country); if (country == null) { EventLogProvider.LogInformation("Import users", "INFO", $"Skipping creation of address of user { userDto.Email }. Reason - invalid country."); return; } var state = FindState(userDto.State); var addressNameFields = new[] { $"{userDto.FirstName} {userDto.LastName}", userDto.AddressLine, userDto.AddressLine2, userDto.City } .Where(af => !string.IsNullOrWhiteSpace(af)); var newAddress = new AddressInfo { AddressName = string.Join(", ", addressNameFields), AddressLine1 = userDto.AddressLine ?? "", AddressLine2 = userDto.AddressLine2, AddressCity = userDto.City ?? "", AddressZip = userDto.PostalCode ?? "", AddressPersonalName = userDto.ContactName ?? $"{userDto.FirstName} {userDto.LastName}", AddressPhone = userDto.PhoneNumber ?? "", AddressCustomerID = customerID, AddressCountryID = country.CountryID, AddressStateID = state?.StateID ?? 0 }; newAddress.SetValue("AddressType", AddressType.Shipping.Code); AddressInfoProvider.SetAddressInfo(newAddress); }
protected void Page_Load(object sender, EventArgs e) { if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Orders.General")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Orders.General"); } this.CurrentMaster.Title.TitleText = GetString("Order_Edit_Address.Title"); rqvCity.ErrorMessage = GetString("Customer_Edit_Address_Edit.rqvCity"); rqvLine.ErrorMessage = GetString("Customer_Edit_Address_Edit.rqvLine"); rqvZipCode.ErrorMessage = GetString("Customer_Edit_Address_Edit.rqvZipCode"); rqvPersonalName.ErrorMessage = GetString("Customer_Edit_Address_Edit.rqvPersonalName"); // control initializations lblAddressZip.Text = GetString("Customer_Edit_Address_Edit.AddressZipLabel"); //lblAddressState.Text = GetString("Customer_Edit_Address_Edit.AddressStateIDLabel"); lblAddressDeliveryPhone.Text = GetString("Customer_Edit_Address_Edit.AddressDeliveryPhoneLabel"); lblAddressCountry.Text = GetString("Customer_Edit_Address_Edit.AddressCountryIDLabel"); //lblAddressName.Text = GetString("Customer_Edit_Address_Edit.AddressNameLabel"); //lblAddressLine3.Text = GetString("Customer_Edit_Address_Edit.AddressLine3Label"); lblAddressLine1.Text = GetString("Customer_Edit_Address_Edit.AddressLine1Label"); //lblAddressLine2.Text = GetString("Customer_Edit_Address_Edit.AddressLine2Label"); lblAddressCity.Text = GetString("Customer_Edit_Address_Edit.AddressCityLabel"); lblPersonalName.Text = GetString("Customer_Edit_Address_Edit.lblPersonalName"); btnOk.Text = GetString("General.OK"); btnCancel.Text = GetString("General.Cancel"); // Get ids from querystring customerId = QueryHelper.GetInteger("customerId", 0); addressId = QueryHelper.GetInteger("addressId", 0); typeId = QueryHelper.GetInteger("typeId", -1); if (addressId > 0) { AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId); EditedObject = addressObj; if (addressObj != null) { // fill editing form if (!RequestHelper.IsPostBack()) { LoadData(addressObj); } } this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_Address/object.png"); } else { if (!RequestHelper.IsPostBack()) { // Init data due to customer settings InitData(); } this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_Address/new.png"); } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { int addressId = ValidationHelper.GetInteger(actionArgument, 0); if (actionName == "edit") { URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerObj.CustomerID + "&addressId=" + addressId); } else if (actionName == "delete") { if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); } var address = AddressInfoProvider.GetAddressInfo(addressId); // Check for the address dependencies if ((address != null) && address.Generalized.CheckDependencies()) { ShowError(ECommerceHelper.GetDependencyMessage(address)); return; } // Delete AddressInfo object from database AddressInfoProvider.DeleteAddressInfo(address); } }
protected void drpAddresses_SelectedIndexChanged(object sender, EventArgs e) { // Get selected address int selectedAddressId = ValidationHelper.GetInteger(drpAddresses.SelectedValue, 0); AddressInfo address = AddressInfoProvider.GetAddressInfo(selectedAddressId); SetupSelectedAddress(address, true); }
internal HoohlShmoohlController() { _model = new HoohlShmoohlModel(); _model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_model_PropertyChanged); _addressProvider = new AddressInfoProvider(this); }
public DeliveryAddress[] GetCustomerShippingAddresses(int customerId) { var addresses = AddressInfoProvider.GetAddresses(customerId) .Where(a => a.GetStringValue("AddressType", string.Empty) == AddressType.Shipping) .ToArray(); return(_mapper.Map <DeliveryAddress[]>(addresses.ToArray())); }
private int GetLastUsedAddressId() { var lastAddress = AddressInfoProvider.GetAddresses(mCustomerId) .OrderByDescending("AddressLastModified") .TopN(1) .FirstOrDefault(); return((lastAddress != null) ? lastAddress.AddressID : 0); }
/// <summary> /// On btnOK click, save edited or new created address. /// </summary> protected void btnOK_OnClick(object sender, EventArgs e) { if (mCustomerId != 0) { // Check field emptiness string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine").NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity").NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode").NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result; // Check country presence if ((errorMessage == "") && (ucCountrySelector.CountryID <= 0)) { errorMessage = GetString("countryselector.selectedcountryerr"); } if (errorMessage == "") { AddressInfo ai = null; // Create new addressinfo or get the existing one if (AddressId == 0) { ai = new AddressInfo(); ai.AddressEnabled = true; ai.AddressIsBilling = true; ai.AddressIsShipping = true; ai.AddressIsCompany = true; ai.AddressCustomerID = mCustomerId; } else { ai = AddressInfoProvider.GetAddressInfo(AddressId); } if (ai != null) { ai.AddressPersonalName = txtPersonalName.Text; ai.AddressLine1 = txtAddressLine1.Text; ai.AddressLine2 = txtAddressLine2.Text; ai.AddressCity = txtAddressCity.Text; ai.AddressZip = txtAddressZip.Text; ai.AddressCountryID = ucCountrySelector.CountryID; ai.AddressStateID = ucCountrySelector.StateID; ai.AddressPhone = txtAddressDeliveryPhone.Text; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save addressinfo AddressInfoProvider.SetAddressInfo(ai); AddressId = ai.AddressID; lblInfo.Visible = true; lblAddress.Text = "> " + HTMLHelper.HTMLEncode(ai.AddressName); } } else { lblError.Visible = true; lblError.Text = errorMessage; } } }
public void DeleteAddress(int addressID) { var address = AddressInfoProvider.GetAddressInfo(addressID); if (address != null) { AddressInfoProvider.DeleteAddressInfo(addressID); } }
public DeliveryAddress[] GetCustomerAddresses(int customerId, AddressType addressType) { var query = AddressInfoProvider.GetAddresses(customerId); if (addressType != null) { query = query.Where($"AddressType ='{addressType}'"); } return(_mapper.Map <DeliveryAddress[]>(query.ToArray())); }
public ActionResult DeliveryDetails(DeliveryDetailsViewModel model) { // Gets the user's current shopping cart ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart(); // Gets all enabled shipping options for the shipping option selector SelectList shippingOptions = new SelectList(ShippingOptionInfoProvider.GetShippingOptions(SiteContext.CurrentSiteID, true).ToList(), "ShippingOptionID", "ShippingOptionDisplayName"); // If the ModelState is not valid, assembles the country list and the shipping option list and displays the step again if (!ModelState.IsValid) { model.BillingAddress.Countries = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName"); model.ShippingOption.ShippingOptions = new ShippingOptionViewModel(ShippingOptionInfoProvider.GetShippingOptionInfo(shoppingService.GetShippingOption()), shippingOptions).ShippingOptions; return(View(model)); } // Gets the shopping cart's customer and applies the customer details from the checkout process step var customer = shoppingService.GetCurrentCustomer(); if (customer == null) { UserInfo userInfo = cart.User; if (userInfo != null) { customer = CustomerHelper.MapToCustomer(cart.User); } else { customer = new CustomerInfo(); } } model.Customer.ApplyToCustomer(customer); // Sets the updated customer object to the current shopping cart shoppingService.SetCustomer(customer); // Gets the shopping cart's billing address and applies the billing address from the checkout process step var address = AddressInfoProvider.GetAddressInfo(model.BillingAddress.AddressID) ?? new AddressInfo(); model.BillingAddress.ApplyTo(address); // Sets the address personal name address.AddressPersonalName = $"{customer.CustomerFirstName} {customer.CustomerLastName}"; // Saves the billing address shoppingService.SetBillingAddress(address); // Sets the selected shipping option and evaluates the cart shoppingService.SetShippingOption(model.ShippingOption.ShippingOptionID); // Redirects to the next step of the checkout process return(RedirectToAction("PreviewAndPay")); }
public void SetShoppingCartAddress(int addressId) { var cart = ECommerceContext.CurrentShoppingCart; if (cart.ShoppingCartShippingAddress == null || cart.ShoppingCartShippingAddress.AddressID != addressId) { var address = AddressInfoProvider.GetAddressInfo(addressId); cart.ShoppingCartShippingAddress = address; ShoppingCartInfoProvider.SetShoppingCartInfo(cart); } }
/// <summary> /// Updates business unit for distributor /// </summary> /// <param name="distributorID">Distributor ID</param> public static void UpdateDistributorsBusinessUnit(int distributorID) { AddressInfo distributor = AddressInfoProvider.GetAddressInfo(distributorID); long businessUnitNumber = ValidationHelper.GetLong(Cart.GetValue("BusinessUnitIDForDistributor"), default(long)); if (distributor != null && businessUnitNumber != default(long)) { distributor.SetValue("BusinessUnit", businessUnitNumber); AddressInfoProvider.SetAddressInfo(distributor); } }
private List <AddressInfo> GetMyAddressBookList() { List <AddressInfo> myAddressList = new List <AddressInfo>(); CustomerInfo currentCustomer = CustomerInfoProvider.GetCustomerInfoByUserID(CurrentUser.UserID); if (!DataHelper.DataSourceIsEmpty(currentCustomer)) { myAddressList = AddressInfoProvider.GetAddresses(currentCustomer.CustomerID).Columns("AddressID", "AddressPersonalName").ToList(); } return(myAddressList); }
/// <summary> /// Returns a customer's address with the specified identifier. /// </summary> /// <param name="addressId">Identifier of the customer's address.</param> /// <returns>Customer's address with the specified identifier. Returns <c>null</c> if not found.</returns> public CustomerAddress GetById(int addressId) { var addressInfo = AddressInfoProvider.GetAddressInfo(addressId); if (addressInfo == null) { return(null); } return(new CustomerAddress(addressInfo)); }
private void ReloadShippingAdresses() { //RptPickShippingAddress string where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); string orderby = "AddressID"; DataSet ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { } RptPickShippingAddress.DataSource = ds; RptPickShippingAddress.DataBind(); }
private AddressInfo GetLastUsedAddress() { return(CacheHelper.Cache(() => AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID) .OrderByDescending("AddressLastModified") .TopN(1) .FirstOrDefault(), new CacheSettings(ECommerceSettings.ProvidersCacheMinutes, "GetLastUsedAddressForCustomer", ShoppingCart.ShoppingCartCustomerID) { CacheDependency = CacheHelper.GetCacheDependency(new[] { AddressInfo.OBJECT_TYPE + "|all" }) })); }
/// <summary> /// Saves the address into the database. /// </summary> /// <param name="validate">Specifies whether the validation should be performed.</param> public void Save(bool validate = true) { if (validate) { var result = Validate(); if (result.CheckFailed) { throw new InvalidOperationException(); } } OriginalAddress.AddressName = AddressInfoProvider.GetAddressName(OriginalAddress); AddressInfoProvider.SetAddressInfo(OriginalAddress); }