private string GetStateCodeGivenStateName(string stateName)
        {
            var stateCode = string.Empty;

            try
            {
                var states = HttpRuntime.Cache[StatesCacheKey] as List <KeyValuePair <string, string> >;
                if (states == null)
                {
                    states = GlobalResourceHelper.GetGlobalEnumeratorElements("IndiaStates").ToList();
                    if (states.Count > 0)
                    {
                        HttpRuntime.Cache.Insert(StatesCacheKey, states, null,
                                                 DateTime.Now.AddMinutes(InShippinginfoCacheMinutes),
                                                 Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                    }
                }

                if (states != null && states.Any())
                {
                    stateCode = states.FirstOrDefault(s => s.Value.ToLower() == stateName.ToLower()).Key;
                }
            }
            catch (Exception)
            {
                stateCode = string.Empty;
            }
            return(stateCode);
        }
        private string getShippingInfoForInvoiceToFirm(MyHLShoppingCart shoppingCart)
        {
            List <TaxIdentification> tins = DistributorOrderingProfileProvider.GetTinList(shoppingCart.DistributorID, true);
            TaxIdentification        tid  = null;

            if ((tid = tins.Find(t => t.IDType.Key == "MKTX")) != null && shoppingCart.InvoiceOption == InvoiceHandlingType.RecycleInvoice.ToString())
            {
                var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("InvoiceOptions");

                foreach (var entry in entries)
                {
                    var key = entry.Key;
                    if (key == shoppingCart.InvoiceOption)
                    {
                        var parts = key.Split('_');
                        if (parts.Length > 1)
                        {
                            key = parts[0];
                        }
                        shoppingCart.InvoiceOption = InvoiceHandlingType.WithPackage.ToString();
                        return(" " + entry.Value);
                    }
                }
            }
            return(string.Empty);
        }
Ejemplo n.º 3
0
        private string GetStateCode(string stateName)
        {
            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("IndiaStates");
            var state   = entries.FirstOrDefault(e => e.Value == stateName);

            return(state.Key ?? string.Empty);
        }
        private string GetCustomerShippingSpeed(ServiceProvider.CustomerOrderSvc.CustomerShippingMethod customerShippingSpeed)
        {
            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("CustomerShippingSpeed");

            foreach (var entry in entries.Where(entry => customerShippingSpeed.ToString() == entry.Key.ToString()))
            {
                return(entry.Value);
            }
            return(customerShippingSpeed.ToString());
        }
        private string GetCustomerPaymentMethodChoice(ServiceProvider.CustomerOrderSvc.CustomerPaymentMethodChoice customerPaymentMethodChoice)
        {
            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("CustomerPaymentMethodChoice");

            foreach (var entry in entries.Where(entry => customerPaymentMethodChoice.ToString() == entry.Key.ToString()))
            {
                return(entry.Value);
            }
            return(customerPaymentMethodChoice.ToString());
        }
        private string GetCustomerOrderStatus(CustomerOrderStatusType customerOrderStatusType)
        {
            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("CustomerOrderStatusTypeEnum");

            foreach (var entry in entries.Where(entry => customerOrderStatusType.ToString() == entry.Key.ToString()))
            {
                return(entry.Value);
            }

            return(customerOrderStatusType.ToString());
        }
        public override List <string> GetStatesForCountry(string Country)
        {
            List <string> items = null;

            var resxReader = GlobalResourceHelper.GetGlobalEnumeratorElements("CanadaStates", Thread.CurrentThread.CurrentCulture);

            if (resxReader != null && resxReader.Count() > 0)
            {
                items = (from s in resxReader
                         select string.Format("{0} - {1}", s.Key, s.Value)).ToList <string>();
            }

            return(items);
        }
Ejemplo n.º 8
0
        protected ActionResult HandleAjaxError()
        {
            foreach (var ms in ModelState.Values)
            {
                if (ms.Errors.Count > 0)
                {
                    var error = ms.Errors[0];
                    return(Content(!string.IsNullOrEmpty(error.ErrorMessage)
                        ? error.ErrorMessage
                        : error.Exception.Message));
                }
            }

            return(Content(GlobalResourceHelper.ErrorUnspecified()));
        }
        private void BindStatesReference()
        {
            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("UsaStates", new CultureInfo("en-US"));

            ddlState.Items.Insert(0, new ListItem(string.Empty, string.Empty));

            foreach (var item in entries)
            {
                ddlState.Items.Add(new ListItem {
                    Text = item.Key, Value = item.Key
                });
            }


            ddlState.SelectedIndex = 0;
        }
Ejemplo n.º 10
0
        public IEnumerable <KeyValuePair <string, string> > GetStates(string locale)
        {
            var providerUS    = new ShippingProvider_US();
            var lookupResults = providerUS.GetStatesForCountryToDisplay(locale.Substring(3, 2));

            if (null != lookupResults && lookupResults.Count > 0)
            {
                List <KeyValuePair <string, string> > result = new List <KeyValuePair <string, string> >();
                foreach (var lookupResult in lookupResults)
                {
                    result.Add(new KeyValuePair <string, string>(lookupResult.Substring(0, 2), lookupResult.Replace(lookupResult.Substring(0, 4), "").Trim()));
                }
                return(result);
            }
            return(GlobalResourceHelper.GetGlobalEnumeratorElements("UsaStates", new CultureInfo(locale)));
        }
Ejemplo n.º 11
0
        private void LookupStates()
        {
            dnlState.Items.Clear();

            var sorted = new SortedList <string, ListItem>();

            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("IndiaStates");

            foreach (var entry in entries)
            {
                sorted.Add(entry.Key, new ListItem(entry.Value));
            }

            dnlState.DataSource     = sorted;
            dnlState.DataTextField  = "value";
            dnlState.DataValueField = "key";
            dnlState.DataBind();

            dnlState.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
            dnlState.SelectedIndex = 0;
        }
Ejemplo n.º 12
0
        private void BindInvoiceStatusReference()
        {
            var dictionary    = new Dictionary <string, string>();
            var invoiceStatus = Enum.GetNames(typeof(InvoiceStatus)).ToList();
            var entries       = GlobalResourceHelper.GetGlobalEnumeratorElements("InvoiceStatusTypes");

            foreach (var entry in entries.Reverse().Where(e => invoiceStatus.Contains(e.Key)))
            {
                var statusKey = (int)Enum.Parse(typeof(InvoiceStatus), entry.Key);
                dictionary.Add(statusKey.ToString(CultureInfo.InvariantCulture), entry.Value);
            }


            ddlInvoiceStatus.DataSource     = dictionary;
            ddlInvoiceStatus.DataTextField  = "Value";
            ddlInvoiceStatus.DataValueField = "Key";
            ddlInvoiceStatus.DataBind();

            SetInvoiceStatus(Session["Invoice"] != null ? ((Invoice)Session["Invoice"]).Status : ServiceProvider.OrderSvc.InvoiceStatus.Unpaid);
            BindEditNotes(Session["Invoice"] != null ? ((Invoice)Session["Invoice"]).Notes : "");
            BindEditPaymentAddress(Session["Invoice"] != null ? ((Invoice)Session["Invoice"]).PaymentAddress : "");

            CalculateTax(false);
        }
Ejemplo n.º 13
0
 public BadRequestResult(string message)
     : base(HttpStatusCode.BadRequest, GlobalResourceHelper.ErrorHttpBadRequest()
            + " " + message)
 {
 }
Ejemplo n.º 14
0
 public ForbiddenResult()
     : base(HttpStatusCode.Forbidden, GlobalResourceHelper.ErrorHttpAccessDenied())
 {
 }
        private void populateInvoiceOptions()
        {
            if (_shoppingCart != null && _shoppingCart.DeliveryInfo != null)
            {
                //divInvoiceOptions
                if (_invoiceOptionRBL != null)
                {
                    divInvoiceOptions.Controls.Remove(_invoiceOptionRBL);
                }
                _invoiceOptionRBL = new RadioButtonList();
                _invoiceOptionRBL.EnableViewState = true;
                ListItemCollection result = new ListItemCollection();

                CatalogItemList catItems = CatalogProvider.GetCatalogItems((from c in _shoppingCart.CartItems
                                                                            select c.SKU.Trim()).ToList <string>(),
                                                                           (this.Page as ProductsBase).CountryCode);
                var list = new List <CatalogItem_V01>();
                list.AddRange(catItems.Select(c => c.Value as CatalogItem_V01).ToList <CatalogItem_V01>());
                var invoiceOptions = new List <InvoiceHandlingType>();
                invoiceOptions = ShippingProvider.GetInvoiceOptions(_shoppingCart.DeliveryInfo.Address, list,
                                                                    this.ShoppingCart);
                //CR for Argies and MX
                if (!HLConfigManager.Configurations.CheckoutConfiguration.AlwaysDisplayInvoiceOption &&
                    (null == invoiceOptions || invoiceOptions.Count == 0))
                {
                    this.Visible      = false;
                    _invoiceOptionRBL = null;
                    return;
                }

                var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("InvoiceOptions");

                foreach (var entry in entries)
                {
                    var key   = entry.Key;
                    var parts = key.Split('_');
                    if (parts.Length > 1)
                    {
                        key = parts[0];
                    }
                    var value = entry.Value;
                    if (result.FindByValue(key) == null)
                    {
                        if (invoiceOptions != null)
                        {
                            if (
                                invoiceOptions.Exists(
                                    c => c == (InvoiceHandlingType)Enum.Parse(typeof(InvoiceHandlingType), key)))
                            {
                                var newItem = new ListItem(value, key);
                                if (_invoiceOptionRBL.Items.FindByValue(key) == null)
                                {
                                    _invoiceOptionRBL.Items.Add(newItem);
                                }
                            }
                        }
                        else
                        {
                            _invoiceOptionRBL.Items.Add(new ListItem(value, key));
                        }
                    }
                }
                if (_invoiceOptionRBL.Items.Count > 0)
                {
                    if (!HLConfigManager.Configurations.CheckoutConfiguration.DisableDefaultInvoiceOption)
                    {
                        ListItem defaultOption = null;
                        if (!string.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.DefaultInvoiceOption))
                        {
                            defaultOption =
                                _invoiceOptionRBL.Items.FindByValue(
                                    HLConfigManager.Configurations.CheckoutConfiguration.DefaultInvoiceOption);
                        }
                        if (defaultOption == null && _shoppingCart.Locale != "zh-TW")
                        {
                            // Selecting the first from Shipping rules.
                            defaultOption = _invoiceOptionRBL.Items.FindByValue(invoiceOptions[0].ToString());
                        }
                        if (defaultOption != null)
                        {
                            defaultOption.Selected = true;
                        }
                        else
                        {
                            if (_shoppingCart.Locale == "zh-TW" && _invoiceOptionRBL.Items.Count > 1)
                            {
                                _invoiceOptionRBL.Items[1].Selected = true;
                            }
                            else
                            {
                                _invoiceOptionRBL.Items[0].Selected = true;
                            }
                        }
                    }
                }

                if (_invoiceOptionRBL.Items.Count > 0)
                {
                    _invoiceOptionRBL.AutoPostBack          = true;
                    _invoiceOptionRBL.SelectedIndexChanged += new EventHandler(_invoiceOptionRBL_SelectedIndexChanged);
                }

                divInvoiceOptions.Controls.Add(_invoiceOptionRBL);
            }
        }
Ejemplo n.º 16
0
 public FileNotFoundResult()
     : base(HttpStatusCode.NotFound, GlobalResourceHelper.ErrorHttpNotFound())
 {
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionInfo       sessionInfo      = SessionInfo.GetSessionInfo(DistributorID, Locale);
            CustomerOrder_V01 customerOrderV01 =
                CustomerOrderingProvider.GetCustomerOrderByOrderID(ShoppingCart.CustomerOrderDetail.CustomerOrderID);

            if (customerOrderV01 != null)
            {
                lblCustomerOrderDate.Text = customerOrderV01.Submitted.HasValue
                                                ? customerOrderV01.Submitted.Value.ToString()
                                                : String.Empty;
                lblCustomerOrderNumber.Text = customerOrderV01.FriendlyId;
                lblCustomerName.Text        = String.Format("{0} {1} {2}",
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .First,
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .Middle,
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .Last);

                lblOrderStatus.Text = GetCustomerOrderStatus(customerOrderV01.OrderStatus);

                lblCustomerComments.Text                = customerOrderV01.CustomerNote;
                lblCustomerPaymentPreference.Text       = GetPaymentMethodChoice(customerOrderV01);
                lblCustomerPrefferedShippingMethod.Text =
                    GetCustomerShippingSpeed(((ServiceProvider.CustomerOrderSvc.CustomerShippingInfo_V01)customerOrderV01.Shipping).ShippingSpeed);
                //((CustomerShippingInfo_V01) customerOrderV01.Shipping).ShippingSpeed.ToString();
            }

            if (!sessionInfo.CustomerOrderAddressWasValid)
            {
                lblErrors.Visible = true;
                lblErrors.Text    = GetLocalResourceObject("CustomerAddressNotValid").ToString();
            }

            var dictionary     = new Dictionary <string, string>();
            var orderTagValues = Enum.GetNames(typeof(CustomerOrderStatusTag)).ToList();

            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("DistributorSelfNoteTags");

            dictionary.Add("0", GetLocalResourceObject("Select").ToString());

            foreach (var entry in entries.Where(entry => orderTagValues.Contains(entry.Key)
                                                &&
                                                (CustomerOrderStatusTag)
                                                Enum.Parse(typeof(CustomerOrderStatusTag), entry.Key) !=
                                                CustomerOrderStatusTag.None))
            {
                dictionary.Add(entry.Key, entry.Value);
            }

            ddlNotesToSelf.DataSource     = dictionary;
            ddlNotesToSelf.DataTextField  = "Value";
            ddlNotesToSelf.DataValueField = "Key";
            ddlNotesToSelf.DataBind();

            if (ShoppingCart.CustomerOrderDetail != null)
            {
                if (customerOrderV01 != null)
                {
                    ListItem liSelectedTag = ddlNotesToSelf.Items.FindByValue(customerOrderV01.StatusTag.ToString());
                    if (liSelectedTag != null)
                    {
                        liSelectedTag.Selected = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(sessionInfo.OrderNumber))
            {
                ddlNotesToSelf.Enabled = false;

                if (customerOrderV01.PaymentMethodChoice == ServiceProvider.CustomerOrderSvc.CustomerPaymentMethodChoice.CreditCardOnline)
                {
                    dvPaymentStatus.Visible = true;
                    AuthorizationClientResponseType paymentStatus = GetPaymentStatus(customerOrderV01.CardAuthorizations);
                    if (paymentStatus == AuthorizationClientResponseType.Approved)
                    {
                        lblCustomerPaymentStatus.Text = GetLocalResourceObject("PaymentStatusApproved").ToString();
                    }
                    else
                    {
                        lblCustomerPaymentStatus.Text = GetLocalResourceObject("PaymentStatusDeclined").ToString();
                    }
                }
            }
        }
Ejemplo n.º 18
0
 public BadRequestResult()
     : base(HttpStatusCode.BadRequest, GlobalResourceHelper.ErrorHttpBadRequest())
 {
 }