public ActionResult Configure(FedexShippingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //save settings
            _fedexSettings.Url                      = model.Url;
            _fedexSettings.Key                      = model.Key;
            _fedexSettings.Password                 = model.Password;
            _fedexSettings.AccountNumber            = model.AccountNumber;
            _fedexSettings.MeterNumber              = model.MeterNumber;
            _fedexSettings.DropoffType              = (DropoffType)model.DropoffType;
            _fedexSettings.UseResidentialRates      = model.UseResidentialRates;
            _fedexSettings.ApplyDiscounts           = model.ApplyDiscounts;
            _fedexSettings.AdditionalHandlingCharge = model.AdditionalHandlingCharge;
            _fedexSettings.Street                   = model.Street;
            _fedexSettings.City                     = model.City;
            _fedexSettings.StateOrProvinceCode      = CommonHelper.EnsureMaximumLength(model.StateOrProvinceCode, 2);
            _fedexSettings.PostalCode               = model.PostalCode;
            _fedexSettings.CountryCode              = model.CountryCode;
            _fedexSettings.PackingPackageVolume     = model.PackingPackageVolume;
            _fedexSettings.PackingType              = (PackingType)model.PackingType;
            _fedexSettings.PassDimensions           = model.PassDimensions;



            // Save selected services
            var carrierServicesOfferedDomestic       = new StringBuilder();
            int carrierServicesDomesticSelectedCount = 0;

            if (model.CheckedCarrierServices != null)
            {
                foreach (var cs in model.CheckedCarrierServices)
                {
                    carrierServicesDomesticSelectedCount++;
                    string serviceId = FedexServices.GetServiceId(cs);
                    if (!String.IsNullOrEmpty(serviceId))
                    {
                        carrierServicesOfferedDomestic.AppendFormat("{0}:", serviceId);
                    }
                }
            }
            // Add default options if no services were selected (Priority Mail International, First-Class Mail International Package, and Express Mail International)
            if (carrierServicesDomesticSelectedCount == 0)
            {
                _fedexSettings.CarrierServicesOffered = "FEDEX_2_DAY:PRIORITY_OVERNIGHT:FEDEX_GROUND:GROUND_HOME_DELIVERY:INTERNATIONAL_ECONOMY";
            }
            else
            {
                _fedexSettings.CarrierServicesOffered = carrierServicesOfferedDomestic.ToString();
            }


            _settingService.SaveSetting(_fedexSettings);

            return(Configure());
        }
Example #2
0
        public IActionResult Configure(FedexShippingModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //save settings
            _fedexSettings.Url                      = model.Url;
            _fedexSettings.Key                      = model.Key;
            _fedexSettings.Password                 = model.Password;
            _fedexSettings.AccountNumber            = model.AccountNumber;
            _fedexSettings.MeterNumber              = model.MeterNumber;
            _fedexSettings.DropoffType              = (DropoffType)model.DropoffType;
            _fedexSettings.UseResidentialRates      = model.UseResidentialRates;
            _fedexSettings.ApplyDiscounts           = model.ApplyDiscounts;
            _fedexSettings.AdditionalHandlingCharge = model.AdditionalHandlingCharge;
            _fedexSettings.PackingPackageVolume     = model.PackingPackageVolume;
            _fedexSettings.PackingType              = (PackingType)model.PackingType;
            _fedexSettings.PassDimensions           = model.PassDimensions;

            // Save selected services
            var carrierServicesOfferedDomestic       = new StringBuilder();
            var carrierServicesDomesticSelectedCount = 0;

            if (model.CheckedCarrierServices != null)
            {
                foreach (var cs in model.CheckedCarrierServices)
                {
                    carrierServicesDomesticSelectedCount++;
                    var serviceId = FedexServices.GetServiceId(cs);
                    if (!string.IsNullOrEmpty(serviceId))
                    {
                        carrierServicesOfferedDomestic.AppendFormat("{0}:", serviceId);
                    }
                }
            }
            // Add default options if no services were selected
            if (carrierServicesDomesticSelectedCount == 0)
            {
                _fedexSettings.CarrierServicesOffered = "FEDEX_2_DAY:PRIORITY_OVERNIGHT:FEDEX_GROUND:GROUND_HOME_DELIVERY:INTERNATIONAL_ECONOMY";
            }
            else
            {
                _fedexSettings.CarrierServicesOffered = carrierServicesOfferedDomestic.ToString();
            }

            _settingService.SaveSetting(_fedexSettings);

            _notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

            return(Configure());
        }
        public ActionResult Configure()
        {
            var model = new FedexShippingModel();

            model.Url                      = _fedexSettings.Url;
            model.Key                      = _fedexSettings.Key;
            model.Password                 = _fedexSettings.Password;
            model.AccountNumber            = _fedexSettings.AccountNumber;
            model.MeterNumber              = _fedexSettings.MeterNumber;
            model.DropoffType              = Convert.ToInt32(_fedexSettings.DropoffType);
            model.AvailableDropOffTypes    = _fedexSettings.DropoffType.ToSelectList();
            model.UseResidentialRates      = _fedexSettings.UseResidentialRates;
            model.ApplyDiscounts           = _fedexSettings.ApplyDiscounts;
            model.AdditionalHandlingCharge = _fedexSettings.AdditionalHandlingCharge;
            model.Street                   = _fedexSettings.Street;
            model.City                     = _fedexSettings.City;
            model.StateOrProvinceCode      = _fedexSettings.StateOrProvinceCode;
            model.PostalCode               = _fedexSettings.PostalCode;
            model.CountryCode              = _fedexSettings.CountryCode;
            model.PackingPackageVolume     = _fedexSettings.PackingPackageVolume;
            model.PackingType              = Convert.ToInt32(_fedexSettings.PackingType);
            model.PackingTypeValues        = _fedexSettings.PackingType.ToSelectList();
            model.PassDimensions           = _fedexSettings.PassDimensions;


            var services = new FedexServices();
            // Load service names
            string carrierServicesOfferedDomestic = _fedexSettings.CarrierServicesOffered;

            foreach (string service in services.Services)
            {
                model.AvailableCarrierServices.Add(service);
            }

            if (!String.IsNullOrEmpty(carrierServicesOfferedDomestic))
            {
                foreach (string service in services.Services)
                {
                    string serviceId = FedexServices.GetServiceId(service);
                    if (!String.IsNullOrEmpty(serviceId) && !String.IsNullOrEmpty(carrierServicesOfferedDomestic))
                    {
                        if (carrierServicesOfferedDomestic.Contains(serviceId))
                        {
                            model.CarrierServicesOffered.Add(service);
                        }
                    }
                }
            }

            return(View("Nop.Plugin.Shipping.Fedex.Views.ShippingFedex.Configure", model));
        }
Example #4
0
        public IActionResult Configure()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            var model = new FedexShippingModel()
            {
                Url                      = _fedexSettings.Url,
                Key                      = _fedexSettings.Key,
                Password                 = _fedexSettings.Password,
                AccountNumber            = _fedexSettings.AccountNumber,
                MeterNumber              = _fedexSettings.MeterNumber,
                DropoffType              = Convert.ToInt32(_fedexSettings.DropoffType),
                AvailableDropOffTypes    = _fedexSettings.DropoffType.ToSelectList(),
                UseResidentialRates      = _fedexSettings.UseResidentialRates,
                ApplyDiscounts           = _fedexSettings.ApplyDiscounts,
                AdditionalHandlingCharge = _fedexSettings.AdditionalHandlingCharge,
                PackingPackageVolume     = _fedexSettings.PackingPackageVolume,
                PackingType              = Convert.ToInt32(_fedexSettings.PackingType),
                PackingTypeValues        = _fedexSettings.PackingType.ToSelectList(),
                PassDimensions           = _fedexSettings.PassDimensions
            };

            // Load service names
            var availableServices = new FedexServices().Services;

            model.AvailableCarrierServices = availableServices;
            if (!string.IsNullOrEmpty(_fedexSettings.CarrierServicesOffered))
            {
                foreach (var service in availableServices)
                {
                    var serviceId = FedexServices.GetServiceId(service);
                    if (!string.IsNullOrEmpty(serviceId) && _fedexSettings.CarrierServicesOffered.Contains(serviceId))
                    {
                        model.CarrierServicesOffered.Add(service);
                    }
                }
            }

            return(View("~/Plugins/Shipping.Fedex/Views/Configure.cshtml", model));
        }