예제 #1
0
        /// <summary>
        /// Edits the UPS international shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(28)]
        public void EditSM_UPSInternational()
        {
            #region Arrange
            var smethod0 = new ShippingMethod();
            var store    = _application.CurrentStore;
            var setting  = _irepo.GetEditSMInfo_UPS_Internation(ref store, ref smethod0);

            var smethod1 = _application.OrderServices.ShippingMethods.FindAll(_application.CurrentStore.Id)
                           .FirstOrDefault(x => x.ShippingProviderId.Equals(GetShippingProviderId(smethod0.ShippingProviderId)));

            smethod1.Name   = smethod0.Name;
            smethod1.ZoneId = smethod0.ZoneId;

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            var servicecodes = AvailableServices.FindById(GetShippingProviderId(smethod0.ShippingProviderId), _application.CurrentStore).ListAllServiceCodes();

            foreach (var scode in setting.ServiceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))))
            {
                settings.ServiceCodeFilter.Add(scode);
            }

            smethod1.Settings.Merge(settings);
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Update(smethod1));
        }
예제 #2
0
        /// <summary>
        /// Adds the UPS international shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(27)]
        public void AddSM_UPSInternational()
        {
            #region Arrange
            var smethod0     = new ShippingMethod();
            var store        = _application.CurrentStore;
            var setting      = _irepo.GetAddSMInfo_UPS_Internation(ref store, ref smethod0);
            var spproviderid = GetShippingProviderId(smethod0.ShippingProviderId);
            var smethod1     = new ShippingMethod
            {
                Name               = smethod0.Name,
                StoreId            = _application.CurrentStore.Id,
                ZoneId             = smethod0.ZoneId,
                AdjustmentType     = ShippingMethodAdjustmentType.Amount,
                Adjustment         = 0,
                ShippingProviderId = spproviderid,
            };

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            var servicecodes = AvailableServices.FindById(GetShippingProviderId(smethod0.ShippingProviderId), _application.CurrentStore).ListAllServiceCodes();

            foreach (var scode in setting.ServiceCodeFilter.Select(filter => servicecodes.FirstOrDefault(x => x.DisplayName.Equals(filter.DisplayName))))
            {
                settings.ServiceCodeFilter.Add(scode);
            }

            smethod1.Settings.Merge(settings);
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Create(smethod1));
        }
예제 #3
0
        /// <summary>
        /// Edits the UPS shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(24)]
        public void EditSM_UPS()
        {
            #region Arrange
            var smethod0 = new ShippingMethod();
            var store    = _application.CurrentStore;
            var setting  = _irepo.GetEditSMInfo_UPS(ref store, ref smethod0);

            var smethod1 = _application.OrderServices.ShippingMethods.FindAll(_application.CurrentStore.Id)
                           .FirstOrDefault(x => x.ShippingProviderId.Equals(GetShippingProviderId(smethod0.ShippingProviderId)));

            smethod1.Name   = smethod0.Name;
            smethod1.ZoneId = smethod0.ZoneId;

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            settings.GetAllRates       = setting.GetAllRates;
            settings.ServiceCodeFilter = SetServicesFilterCode("UPS", setting.ServiceCodeFilter);

            smethod1.Settings.Merge(settings);

            _application.CurrentStore.Settings.ShippingFedExAccountNumber  = store.Settings.ShippingUpsAccountNumber;
            _application.CurrentStore.Settings.ShippingUpsForceResidential = store.Settings.ShippingUpsForceResidential;
            _application.CurrentStore.Settings.ShippingUpsPickupType       = store.Settings.ShippingUpsPickupType;
            _application.CurrentStore.Settings.ShippingUpsDefaultService   = store.Settings.ShippingUpsDefaultService;
            _application.CurrentStore.Settings.ShippingUpsDefaultPackaging = store.Settings.ShippingUpsDefaultPackaging;
            _application.CurrentStore.Settings.ShippingUpsSkipDimensions   = store.Settings.ShippingUpsSkipDimensions;
            _application.CurrentStore.Settings.ShippingUPSDiagnostics      = store.Settings.ShippingUPSDiagnostics;
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Update(smethod1));
        }
예제 #4
0
        private void SaveData()
        {
            ShippingMethod.Name           = NameField.Text.Trim();
            ShippingMethod.ZoneId         = long.Parse(lstZones.SelectedItem.Value);
            ShippingMethod.AdjustmentType =
                (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue);
            ShippingMethod.Adjustment = decimal.Parse(AdjustmentTextBox.Text, NumberStyles.Currency);

            if (ShippingMethod.AdjustmentType == ShippingMethodAdjustmentType.Amount)
            {
                ShippingMethod.Adjustment = Money.RoundCurrency(ShippingMethod.Adjustment);
            }

            // Global Settings
            HccApp.CurrentStore.Settings.ShippingUpsAccountNumber    = AccountNumberField.Text.Trim();
            HccApp.CurrentStore.Settings.ShippingUpsForceResidential = ResidentialAddressCheckBox.Checked;
            HccApp.CurrentStore.Settings.ShippingUpsPickupType       = int.Parse(PickupTypeRadioButtonList.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsDefaultService   = int.Parse(DefaultServiceField.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsDefaultPackaging = int.Parse(DefaultPackagingField.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsSkipDimensions   = SkipDimensionsCheckBox.Checked;
            HccApp.CurrentStore.Settings.ShippingUPSDiagnostics      = chkDiagnostics.Checked;

            // Method Settings
            var Settings = new UPSServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            var filter = new List <IServiceCode>();

            if (rbFilterMode.SelectedValue == "0")
            {
                Settings.GetAllRates = false;

                foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        var code = new ServiceCode {
                            Code = item.Value, DisplayName = item.Text
                        };
                        filter.Add(code);
                    }
                }
            }
            else
            {
                Settings.GetAllRates = true;
            }

            Settings.ServiceCodeFilter = filter;
            Settings["highlight"]      = lstHighlights.SelectedValue;
            ShippingMethod.Settings.Merge(Settings);

            HccApp.AccountServices.Stores.Update(HccApp.CurrentStore);
        }
예제 #5
0
        private void SaveData()
        {
            ShippingMethod.Name           = this.NameField.Text.Trim();
            ShippingMethod.ZoneId         = long.Parse(this.lstZones.SelectedItem.Value);
            ShippingMethod.AdjustmentType = (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue);
            ShippingMethod.Adjustment     = decimal.Parse(AdjustmentTextBox.Text, System.Globalization.NumberStyles.Currency);

            // Global Settings
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsAccountNumber    = this.AccountNumberField.Text.Trim();
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsForceResidential = this.ResidentialAddressCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsPickupType       = int.Parse(this.PickupTypeRadioButtonList.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultService   = int.Parse(this.DefaultServiceField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultPackaging = int.Parse(this.DefaultPackagingField.SelectedValue);
            //MyPage.Services.CurrentStore.Settings.ShippingUpsDefaultPayment = int.Parse(this.DefaultPaymentField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsSkipDimensions = this.SkipDimensionsCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUPSDiagnostics    = this.chkDiagnostics.Checked;



            // Method Settings
            UPSServiceSettings Settings = new UPSServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            List <MerchantTribe.Shipping.IServiceCode> filter = new List <MerchantTribe.Shipping.IServiceCode>();

            if (this.rbFilterMode.SelectedValue == "0")
            {
                Settings.GetAllRates = false;

                foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode()
                        {
                            Code = item.Value, DisplayName = item.Text
                        };
                        filter.Add(code);
                    }
                }
            }
            else
            {
                Settings.GetAllRates = true;
            }

            Settings.ServiceCodeFilter = filter;
            Settings["highlight"]      = this.lstHighlights.SelectedValue;
            ShippingMethod.Settings.Merge(Settings);

            MyPage.MTApp.AccountServices.Stores.Update(MyPage.MTApp.CurrentStore);
        }
예제 #6
0
        /// <summary>
        /// Adds the UPS shipping method.
        /// </summary>
        //[TestMethod]
        //[Priority(23)]
        public void AddSM_UPS()
        {
            #region Arrange
            var smethod0     = new ShippingMethod();
            var store        = _application.CurrentStore;
            var setting      = _irepo.GetAddSMInfo_UPS(ref store, ref smethod0);
            var spproviderid = GetShippingProviderId(smethod0.ShippingProviderId);
            var smethod1     = new ShippingMethod
            {
                Name               = smethod0.Name,
                StoreId            = _application.CurrentStore.Id,
                ZoneId             = smethod0.ZoneId,
                AdjustmentType     = ShippingMethodAdjustmentType.Amount,
                Adjustment         = 0,
                ShippingProviderId = spproviderid,
            };

            var settings = new UPSServiceSettings();
            settings.Merge(smethod1.Settings);
            settings.GetAllRates       = setting.GetAllRates;
            settings.ServiceCodeFilter = SetServicesFilterCode("UPS", setting.ServiceCodeFilter);

            smethod1.Settings.Merge(settings);

            _application.CurrentStore.Settings.ShippingFedExAccountNumber  = store.Settings.ShippingUpsAccountNumber;
            _application.CurrentStore.Settings.ShippingUpsForceResidential = store.Settings.ShippingUpsForceResidential;
            _application.CurrentStore.Settings.ShippingUpsPickupType       = store.Settings.ShippingUpsPickupType;
            _application.CurrentStore.Settings.ShippingUpsDefaultService   = store.Settings.ShippingUpsDefaultService;
            _application.CurrentStore.Settings.ShippingUpsDefaultPackaging = store.Settings.ShippingUpsDefaultPackaging;
            _application.CurrentStore.Settings.ShippingUpsSkipDimensions   = store.Settings.ShippingUpsSkipDimensions;
            _application.CurrentStore.Settings.ShippingUPSDiagnostics      = store.Settings.ShippingUPSDiagnostics;
            #endregion

            //Act/Assert
            Assert.IsTrue(_application.OrderServices.ShippingMethods.Create(smethod1));
        }
예제 #7
0
        private void LoadData()
        {
            // Name
            this.NameField.Text = ShippingMethod.Name;
            if (this.NameField.Text == string.Empty)
            {
                this.NameField.Text = "UPS Shipping";
            }

            // Adjustment
            AdjustmentDropDownList.SelectedValue = ((int)ShippingMethod.AdjustmentType).ToString();
            if (ShippingMethod.AdjustmentType == ShippingMethodAdjustmentType.Amount)
            {
                AdjustmentTextBox.Text = string.Format("{0:c}", ShippingMethod.Adjustment);
            }
            else
            {
                AdjustmentTextBox.Text = string.Format("{0:f}", ShippingMethod.Adjustment);
            }


            // Zones
            if (this.lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()) != null)
            {
                this.lstZones.ClearSelection();
                this.lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()).Selected = true;
            }

            // Global Settings
            this.AccountNumberField.Text                 = MyPage.MTApp.CurrentStore.Settings.ShippingUpsAccountNumber;
            this.ResidentialAddressCheckBox.Checked      = MyPage.MTApp.CurrentStore.Settings.ShippingUpsForceResidential;
            this.PickupTypeRadioButtonList.SelectedValue = MyPage.MTApp.CurrentStore.Settings.ShippingUpsPickupType.ToString();
            this.DefaultPackagingField.SelectedValue     = MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultPackaging.ToString();
            //this.DefaultPaymentField.SelectedValue = MyPage.Services.CurrentStore.ShippingUpsDefaultPayment.ToString();
            this.DefaultServiceField.SelectedValue = MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultService.ToString();
            if (MyPage.MTApp.CurrentStore.Settings.ShippingUpsLicense.Trim().Length > 0)
            {
                this.lnkRegister.Text = "Already Registered with UPS (click to register again)";
            }
            else
            {
                this.lnkRegister.Text = "Register with UPS to use Online Tools";
            }
            this.SkipDimensionsCheckBox.Checked = MyPage.MTApp.CurrentStore.Settings.ShippingUpsSkipDimensions;
            this.chkDiagnostics.Checked         = MyPage.MTApp.CurrentStore.Settings.ShippingUPSDiagnostics;


            // Method Settings
            UPSServiceSettings Settings = new UPSServiceSettings();

            Settings.Merge(ShippingMethod.Settings);


            if (Settings.ServiceCodeFilter == null)
            {
                Settings.ServiceCodeFilter = new List <MerchantTribe.Shipping.IServiceCode>();
            }

            if (Settings.ServiceCodeFilter.Count < 1 || Settings.GetAllRates)
            {
                this.litMessage.Text = "Setting rbfilter to 1";

                if (rbFilterMode.Items.FindByValue("1") != null)
                {
                    this.rbFilterMode.ClearSelection();
                    this.rbFilterMode.Items.FindByValue("1").Selected = true;
                }
            }
            else
            {
                this.litMessage.Text = "Setting rbfilter to 0";
                if (rbFilterMode.Items.FindByValue("0") != null)
                {
                    this.rbFilterMode.ClearSelection();
                    this.rbFilterMode.Items.FindByValue("0").Selected = true;
                }

                foreach (MerchantTribe.Shipping.ServiceCode code in Settings.ServiceCodeFilter)
                {
                    foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                    {
                        if (string.Compare(item.Value, code.Code, true) == 0)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }
        }
예제 #8
0
        private void LoadData()
        {
            // Name
            NameField.Text = ShippingMethod.Name;

            if (string.IsNullOrEmpty(NameField.Text))
            {
                NameField.Text = Localization.GetString("UPSShipping");
            }

            // Adjustment
            AdjustmentDropDownList.SelectedValue = ((int)ShippingMethod.AdjustmentType).ToString();

            if (ShippingMethod.AdjustmentType == ShippingMethodAdjustmentType.Amount)
            {
                AdjustmentTextBox.Text = string.Format("{0:c}", ShippingMethod.Adjustment);
            }
            else
            {
                AdjustmentTextBox.Text = string.Format("{0:f}", ShippingMethod.Adjustment);
            }

            // Zones
            if (lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()) != null)
            {
                lstZones.ClearSelection();
                lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()).Selected = true;
            }

            // Global Settings
            AccountNumberField.Text                 = HccApp.CurrentStore.Settings.ShippingUpsAccountNumber;
            ResidentialAddressCheckBox.Checked      = HccApp.CurrentStore.Settings.ShippingUpsForceResidential;
            PickupTypeRadioButtonList.SelectedValue = HccApp.CurrentStore.Settings.ShippingUpsPickupType.ToString();
            DefaultPackagingField.SelectedValue     = HccApp.CurrentStore.Settings.ShippingUpsDefaultPackaging.ToString();
            DefaultServiceField.SelectedValue       = HccApp.CurrentStore.Settings.ShippingUpsDefaultService.ToString();

            if (HccApp.CurrentStore.Settings.ShippingUpsLicense.Trim().Length > 0)
            {
                lnkRegister.Text = Localization.GetString("AlreadyRegistered");
            }
            else
            {
                lnkRegister.Text = Localization.GetString("RegisterWithUPS");
            }

            SkipDimensionsCheckBox.Checked = HccApp.CurrentStore.Settings.ShippingUpsSkipDimensions;
            chkDiagnostics.Checked         = HccApp.CurrentStore.Settings.ShippingUPSDiagnostics;

            // Method Settings
            var Settings = new UPSServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            if (Settings.ServiceCodeFilter == null)
            {
                Settings.ServiceCodeFilter = new List <IServiceCode>();
            }

            if (Settings.ServiceCodeFilter.Count < 1 || Settings.GetAllRates)
            {
                if (rbFilterMode.Items.FindByValue("1") != null)
                {
                    rbFilterMode.ClearSelection();
                    rbFilterMode.Items.FindByValue("1").Selected = true;
                }
            }
            else
            {
                if (rbFilterMode.Items.FindByValue("0") != null)
                {
                    rbFilterMode.ClearSelection();
                    rbFilterMode.Items.FindByValue("0").Selected = true;
                }

                foreach (ServiceCode code in Settings.ServiceCodeFilter)
                {
                    foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                    {
                        if (string.Compare(item.Value, code.Code, true) == 0)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }

            ToggleFilterMode();

            // Select Hightlights
            var highlight = Settings.GetSettingOrEmpty("highlight");

            if (lstHighlights.Items.FindByText(highlight) != null)
            {
                lstHighlights.ClearSelection();
                lstHighlights.Items.FindByText(highlight).Selected = true;
            }
        }