Exemplo n.º 1
0
        public ActionResult AddPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var sbw = new ShippingByWeightRecord()
            {
                CountryId        = model.CountryId,
                StateProvinceId  = model.StateProvinceId,
                Zip              = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId = model.ShippingMethodId,
                From             = model.From,
                To = model.To,
                AdditionalFixedCost      = model.AdditionalFixedCost,
                RatePerWeightUnit        = model.RatePerWeightUnit,
                PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
                LowerWeightLimit         = model.LowerWeightLimit
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.AddPopup", model));
        }
Exemplo n.º 2
0
        public IActionResult AddPopup(ShippingByWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var sbw = new ShippingByWeightRecord
            {
                StoreId          = model.StoreId,
                WarehouseId      = model.WarehouseId,
                CountryId        = model.CountryId,
                StateProvinceId  = model.StateProvinceId,
                Zip              = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId = model.ShippingMethodId,
                From             = model.From,
                To = model.To,
                AdditionalFixedCost      = model.AdditionalFixedCost,
                RatePerWeightUnit        = model.RatePerWeightUnit,
                PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
                LowerWeightLimit         = model.LowerWeightLimit
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Shipping.ByWeight/Views/AddPopup.cshtml", model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> EditPopup(ShippingByWeightModel model)
        {
            var sbw = await _shippingByWeightService.GetById(model.Id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            sbw.StoreId          = model.StoreId;
            sbw.WarehouseId      = model.WarehouseId;
            sbw.CountryId        = model.CountryId;
            sbw.StateProvinceId  = model.StateProvinceId;
            sbw.Zip              = model.Zip == "*" ? null : model.Zip;
            sbw.ShippingMethodId = model.ShippingMethodId;
            sbw.From             = model.From;
            sbw.To = model.To;
            sbw.AdditionalFixedCost      = model.AdditionalFixedCost;
            sbw.RatePerWeightUnit        = model.RatePerWeightUnit;
            sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;
            sbw.LowerWeightLimit         = model.LowerWeightLimit;
            await _shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Shipping.ByWeight/Views/EditPopup.cshtml", model));
        }
Exemplo n.º 4
0
        public IActionResult EditPopup(ShippingByWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var sbw = _shippingByWeightService.GetById(model.Id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            sbw.StoreId          = model.StoreId;
            sbw.WarehouseId      = model.WarehouseId;
            sbw.CountryId        = model.CountryId;
            sbw.StateProvinceId  = model.StateProvinceId;
            sbw.Zip              = model.Zip == "*" ? null : model.Zip;
            sbw.ShippingMethodId = model.ShippingMethodId;
            sbw.From             = model.From;
            sbw.To = model.To;
            sbw.AdditionalFixedCost      = model.AdditionalFixedCost;
            sbw.RatePerWeightUnit        = model.RatePerWeightUnit;
            sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;
            sbw.LowerWeightLimit         = model.LowerWeightLimit;
            _shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Shipping.ByWeight/Views/EditPopup.cshtml", model));
        }
        public ActionResult AddRateByWeighPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var sbw = new ShippingByWeightRecord
            {
                StoreId          = model.StoreId,
                WarehouseId      = model.WarehouseId,
                CountryId        = model.CountryId,
                StateProvinceId  = model.StateProvinceId,
                Zip              = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId = model.ShippingMethodId,
                From             = model.From,
                To = model.To,
                AdditionalFixedCost      = model.AdditionalFixedCost,
                RatePerWeightUnit        = model.RatePerWeightUnit,
                PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
                LowerWeightLimit         = model.LowerWeightLimit
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;

            return(View("~/Plugins/Shipping.FixedOrByWeight/Views/AddRateByWeightPopup.cshtml", model));
        }
Exemplo n.º 6
0
        public ActionResult AddRateByWeighPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            //    return RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl });

            //var sbw = new ShippingByWeightRecord
            //{
            //    StoreId = model.StoreId,
            //    WarehouseId = model.WarehouseId,
            //    CountryId = model.CountryId,
            //    StateProvinceId = model.StateProvinceId,
            //    Zip = model.Zip == "*" ? null : model.Zip,
            //    ShippingMethodId = model.ShippingMethodId,
            //    From = model.From,
            //    To = model.To,
            //    AdditionalFixedCost = model.AdditionalFixedCost,
            //    RatePerWeightUnit = model.RatePerWeightUnit,
            //    PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
            //    LowerWeightLimit = model.LowerWeightLimit
            //};
            ////_shippingByWeightService.InsertShippingByWeightRecord(sbw);

            //ViewBag.RefreshPage = true;
            //ViewBag.btnId = btnId;
            //ViewBag.formId = formId;

            //return View("~/Plugins/Shipping.JDFreight/Views/AddRateByWeightPopup.cshtml", model);
            return(null);
        }
Exemplo n.º 7
0
        public ActionResult EditPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            var sbw = _shippingByWeightService.GetById(model.Id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            sbw.CountryId        = model.CountryId;
            sbw.StateProvinceId  = model.StateProvinceId;
            sbw.Zip              = model.Zip == "*" ? null : model.Zip;
            sbw.ShippingMethodId = model.ShippingMethodId;
            sbw.From             = model.From;
            sbw.To = model.To;
            sbw.AdditionalFixedCost      = model.AdditionalFixedCost;
            sbw.RatePerWeightUnit        = model.RatePerWeightUnit;
            sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;
            sbw.LowerWeightLimit         = model.LowerWeightLimit;
            _shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.EditPopup", model));
        }
Exemplo n.º 8
0
        public ActionResult EditRateByWeighPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            //    return RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl });

            //var sbw = _shippingByWeightService.GetById(model.Id);
            //if (sbw == null)
            //    //no record found with the specified id
            //    return RedirectToAction("Configure");

            //sbw.StoreId = model.StoreId;
            //sbw.WarehouseId = model.WarehouseId;
            //sbw.CountryId = model.CountryId;
            //sbw.StateProvinceId = model.StateProvinceId;
            //sbw.Zip = model.Zip == "*" ? null : model.Zip;
            //sbw.ShippingMethodId = model.ShippingMethodId;
            //sbw.From = model.From;
            //sbw.To = model.To;
            //sbw.AdditionalFixedCost = model.AdditionalFixedCost;
            //sbw.RatePerWeightUnit = model.RatePerWeightUnit;
            //sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;
            //sbw.LowerWeightLimit = model.LowerWeightLimit;
            //_shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            //ViewBag.RefreshPage = true;
            //ViewBag.btnId = btnId;
            //ViewBag.formId = formId;

            //return View("~/Plugins/Shipping.JDFreight/Views/EditRateByWeightPopup.cshtml", model);

            return(null);
        }
Exemplo n.º 9
0
        public IActionResult RateByWeightList(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            var records  = _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);
            var sbwModel = records.Select(record =>
            {
                var model = new ShippingByWeightModel
                {
                    Id                       = record.Id,
                    StoreId                  = record.StoreId,
                    StoreName                = _storeService.GetStoreById(record.StoreId)?.Name ?? "*",
                    WarehouseId              = record.WarehouseId,
                    WarehouseName            = _shippingService.GetWarehouseById(record.WarehouseId)?.Name ?? "*",
                    ShippingMethodId         = record.ShippingMethodId,
                    ShippingMethodName       = _shippingService.GetShippingMethodById(record.ShippingMethodId)?.Name ?? "Unavailable",
                    CountryId                = record.CountryId,
                    CountryName              = _countryService.GetCountryById(record.CountryId)?.Name ?? "*",
                    StateProvinceId          = record.StateProvinceId,
                    StateProvinceName        = _stateProvinceService.GetStateProvinceById(record.StateProvinceId)?.Name ?? "*",
                    From                     = record.From,
                    To                       = record.To,
                    AdditionalFixedCost      = record.AdditionalFixedCost,
                    PercentageRateOfSubtotal = record.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = record.RatePerWeightUnit,
                    LowerWeightLimit         = record.LowerWeightLimit,
                    Zip                      = !string.IsNullOrEmpty(record.Zip) ? record.Zip : "*"
                };

                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.From"), model.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.To"), model.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.AdditionalFixedCost"), model.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.RatePerWeightUnit"), model.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.LowerWeightLimit"), model.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedOrByWeight.Fields.PercentageRateOfSubtotal"), model.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                model.DataHtml = htmlSb.ToString();

                return(model);
            }).ToList();

            var gridModel = new DataSourceResult
            {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }
Exemplo n.º 10
0
        public ActionResult RatesList(GridCommand command)
        {
            var records  = _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);
            var sbwModel = records.Select(x =>
            {
                var m = new ShippingByWeightModel()
                {
                    Id = x.Id,
                    ShippingMethodId = x.ShippingMethodId,
                    CountryId        = x.CountryId,
                    From             = x.From,
                    To = x.To,
                    AdditionalFixedCost      = x.AdditionalFixedCost,
                    PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = x.RatePerWeightUnit,
                    LowerWeightLimit         = x.LowerWeightLimit,
                };
                var shippingMethod   = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                var c               = _countryService.GetCountryById(x.CountryId);
                m.CountryName       = (c != null) ? c.Name : "*";
                var s               = _stateProvinceService.GetStateProvinceById(x.StateProvinceId);
                m.StateProvinceName = (s != null) ? s.Name : "*";
                m.Zip               = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";


                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.From"), m.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.To"), m.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit"), m.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit"), m.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal"), m.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                m.DataHtml = htmlSb.ToString();

                return(m);
            })
                           .ToList();
            var model = new GridModel <ShippingByWeightModel>
            {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(new JsonResult
            {
                Data = model
            });
        }
        //add
        public ActionResult AddPopup()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var model = new ShippingByWeightModel();

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;
            model.To = 1000000;

            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString()
                });
            }
            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem {
                    Text = sm.Name, Value = sm.Id.ToString()
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            var countries = _countryService.GetAllCountries(true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString()
                });
            }
            //states
            model.AvailableStates.Add(new SelectListItem {
                Text = "*", Value = "0"
            });

            return(View("~/Plugins/Shipping.ByWeight/Views/ShippingByWeight/AddPopup.cshtml", model));
        }
Exemplo n.º 12
0
        public ActionResult RateUpdate(ShippingByWeightModel model, GridCommand command)
        {
            var sbw = _shippingByWeightService.GetById(model.Id);

            sbw.From                     = model.From;
            sbw.To                       = model.To;
            sbw.UsePercentage            = model.UsePercentage;
            sbw.ShippingChargeAmount     = model.ShippingChargeAmount;
            sbw.ShippingChargePercentage = model.ShippingChargePercentage;
            _shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            return(RatesList(command));
        }
        public ActionResult RateUpdate(ShippingByWeightModel model, GridCommand command)
        {
            var sbw = _shippingByWeightService.GetById(model.Id);

            sbw.From                     = model.From;
            sbw.To                       = model.To;
            sbw.UsePercentage            = model.UsePercentage;
            sbw.Zip                      = model.Zip == "*" ? null : model.Zip;
            sbw.ShippingChargeAmount     = model.ShippingChargeAmount;
            sbw.ShippingChargePercentage = model.ShippingChargePercentage;
            sbw.SmallQuantitySurcharge   = model.SmallQuantitySurcharge;
            sbw.SmallQuantityThreshold   = model.SmallQuantityThreshold;
            _shippingByWeightService.UpdateShippingByWeightRecord(sbw);

            return(RatesList(command));
        }
Exemplo n.º 14
0
        public ActionResult RatesList(GridCommand command)
        {
            var sbwModel = _shippingByWeightService.GetAll()
                           .Select(x =>
            {
                var m = new ShippingByWeightModel()
                {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    UsePercentage            = x.UsePercentage,
                    ShippingChargePercentage = x.ShippingChargePercentage,
                    ShippingChargeAmount     = x.ShippingChargeAmount,
                };
                //shipping method
                var shippingMethodId = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethodId != null) ? shippingMethodId.Name : "Unavailable";
                //store
                var store   = _storeService.GetStoreById(x.StoreId);
                m.StoreName = (store != null) ? store.Name : "*";
                if (x.CountryId > 0)
                {
                    var c         = _countryService.GetCountryById(x.CountryId);
                    m.CountryName = (c != null) ? c.Name : "Unavailable";
                }
                else
                {
                    m.CountryName = "*";
                }
                return(m);
            })
                           .ToList();
            var model = new GridModel <ShippingByWeightModel>
            {
                Data  = sbwModel,
                Total = sbwModel.Count
            };

            return(new JsonResult
            {
                Data = model
            });
        }
        /// <summary>
        /// Get models for shipping by weight records
        /// </summary>
        public virtual IList <ShippingByWeightModel> GetShippingByWeightModels(int pageIndex, int pageSize, out int totalCount)
        {
            // data join would be much better but not possible here cause ShippingByWeightObjectContext cannot be shared across repositories
            var records = GetShippingByWeightRecords(pageIndex, pageSize);

            totalCount = records.TotalCount;

            if (records.Count <= 0)
            {
                return(new List <ShippingByWeightModel>());
            }

            var allStores = _storeService.GetAllStores();

            var result = records.Select(x =>
            {
                var store          = allStores.FirstOrDefault(y => y.Id == x.StoreId);
                var shippingMethod = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                var country        = _countryService.GetCountryById(x.CountryId);

                var model = new ShippingByWeightModel()
                {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    Zip                      = (x.Zip.HasValue() ? x.Zip : "*"),
                    UsePercentage            = x.UsePercentage,
                    ShippingChargePercentage = x.ShippingChargePercentage,
                    ShippingChargeAmount     = x.ShippingChargeAmount,
                    SmallQuantitySurcharge   = x.SmallQuantitySurcharge,
                    SmallQuantityThreshold   = x.SmallQuantityThreshold,
                    StoreName                = (store == null ? "*" : store.Name),
                    ShippingMethodName       = (shippingMethod == null ? "".NaIfEmpty() : shippingMethod.Name),
                    CountryName              = (country == null ? "*" : country.Name)
                };

                return(model);
            })
                         .ToList();

            return(result);
        }
Exemplo n.º 16
0
        //add
        public ActionResult AddPopup()
        {
            var model = new ShippingByWeightModel();

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;
            model.To = 1000000;

            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem()
                {
                    Text = sm.Name, Value = sm.Id.ToString()
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            var countries = _countryService.GetAllCountries(true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem()
                {
                    Text = c.Name, Value = c.Id.ToString()
                });
            }
            //states
            model.AvailableStates.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });

            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.AddPopup", model));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> AddPopup(ShippingByWeightModel model)
        {
            var sbw = new ShippingByWeightRecord {
                StoreId          = model.StoreId,
                WarehouseId      = model.WarehouseId,
                CountryId        = model.CountryId,
                StateProvinceId  = model.StateProvinceId,
                Zip              = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId = model.ShippingMethodId,
                From             = model.From,
                To = model.To,
                AdditionalFixedCost      = model.AdditionalFixedCost,
                RatePerWeightUnit        = model.RatePerWeightUnit,
                PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
                LowerWeightLimit         = model.LowerWeightLimit
            };
            await _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Shipping.ByWeight/Views/AddPopup.cshtml", model));
        }
Exemplo n.º 18
0
        public ActionResult AddPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            var sbw = new ShippingByWeightRecord()
            {
                CountryId        = model.CountryId,
                StateProvinceId  = model.StateProvinceId,
                Zip              = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId = model.ShippingMethodId,
                From             = model.From,
                To = model.To,
                AdditionalFixedCost      = model.AdditionalFixedCost,
                RatePerWeightUnit        = model.RatePerWeightUnit,
                PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,
                LowerWeightLimit         = model.LowerWeightLimit
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;
            ViewBag.btnId       = btnId;
            ViewBag.formId      = formId;
            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.AddPopup", model));
        }
Exemplo n.º 19
0
        public ActionResult RatesList(GridCommand command)
        {
            var sbwModel = _shippingByWeightService.GetAll()
                           .Select(x =>
            {
                var m = new ShippingByWeightModel()
                {
                    Id = x.Id,
                    ShippingMethodId = x.ShippingMethodId,
                    CountryId        = x.CountryId,
                    From             = x.From,
                    To                       = x.To,
                    UsePercentage            = x.UsePercentage,
                    ShippingChargePercentage = x.ShippingChargePercentage,
                    ShippingChargeAmount     = x.ShippingChargeAmount,
                };
                var shippingMethod   = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                var c               = _countryService.GetCountryById(x.CountryId);
                m.CountryName       = (c != null) ? c.Name : "*";
                var s               = _stateProvinceService.GetStateProvinceById(x.StateProvinceId);
                m.StateProvinceName = (s != null) ? s.Name : "*";
                m.Zip               = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";
                return(m);
            })
                           .ToList();
            var model = new GridModel <ShippingByWeightModel>
            {
                Data  = sbwModel,
                Total = sbwModel.Count
            };

            return(new JsonResult
            {
                Data = model
            });
        }
Exemplo n.º 20
0
        public ActionResult AddRateByWeighPopup()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var model = new ShippingByWeightModel
            {
                PrimaryStoreCurrencyCode =
                    _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                BaseWeightIn = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name,
                To           = 1000000
            };

            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (!shippingMethods.Any())
            {
                return(Content("No shipping methods can be loaded"));
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString()
                });
            }
            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            foreach (var warehouses in _shippingService.GetAllWarehouses())
            {
                model.AvailableWarehouses.Add(new SelectListItem {
                    Text = warehouses.Name, Value = warehouses.Id.ToString()
                });
            }
            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem {
                    Text = sm.Name, Value = sm.Id.ToString()
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem {
                Text = "*", Value = "0"
            });
            var countries = _countryService.GetAllCountries(showHidden: true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString()
                });
            }
            //states
            model.AvailableStates.Add(new SelectListItem {
                Text = "*", Value = "0"
            });

            return(View("~/Plugins/Shipping.JDFreight/Views/AddRateByWeightPopup.cshtml", model));
        }
Exemplo n.º 21
0
        public IActionResult RatesList(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var records  = _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);
            var sbwModel = records.Select(x =>
            {
                var m = new ShippingByWeightModel
                {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    WarehouseId              = x.WarehouseId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    AdditionalFixedCost      = x.AdditionalFixedCost,
                    PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = x.RatePerWeightUnit,
                    LowerWeightLimit         = x.LowerWeightLimit,
                };
                //shipping method
                var shippingMethod   = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                //store
                var store   = _storeService.GetStoreById(x.StoreId);
                m.StoreName = (store != null) ? store.Name : "*";
                //warehouse
                var warehouse   = _shippingService.GetWarehouseById(x.WarehouseId);
                m.WarehouseName = (warehouse != null) ? warehouse.Name : "*";
                //country
                var c         = _countryService.GetCountryById(x.CountryId);
                m.CountryName = (c != null) ? c.Name : "*";
                //state
                var s = _stateProvinceService.GetStateProvinceById(x.StateProvinceId);
                m.StateProvinceName = (s != null) ? s.Name : "*";
                //zip
                m.Zip = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";


                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.From"), m.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.To"), m.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit"), m.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit"), m.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal"), m.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                m.DataHtml = htmlSb.ToString();

                return(m);
            })
                           .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }
Exemplo n.º 22
0
        //edit
        public IActionResult EditPopup(string id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var sbw = _shippingByWeightService.GetById(id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            var model = new ShippingByWeightModel
            {
                Id                       = sbw.Id,
                StoreId                  = sbw.StoreId,
                WarehouseId              = sbw.WarehouseId,
                CountryId                = sbw.CountryId,
                StateProvinceId          = sbw.StateProvinceId,
                Zip                      = sbw.Zip,
                ShippingMethodId         = sbw.ShippingMethodId,
                From                     = sbw.From,
                To                       = sbw.To,
                AdditionalFixedCost      = sbw.AdditionalFixedCost,
                PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal,
                RatePerWeightUnit        = sbw.RatePerWeightUnit,
                LowerWeightLimit         = sbw.LowerWeightLimit,
                PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name
            };

            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            var selectedStore          = _storeService.GetStoreById(sbw.StoreId);
            var selectedWarehouse      = _shippingService.GetWarehouseById(sbw.WarehouseId);
            var selectedShippingMethod = _shippingService.GetShippingMethodById(sbw.ShippingMethodId);
            var selectedCountry        = _countryService.GetCountryById(sbw.CountryId);
            var selectedState          = _stateProvinceService.GetStateProvinceById(sbw.StateProvinceId);

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var store in _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }
            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var warehouse in _shippingService.GetAllWarehouses())
            {
                model.AvailableWarehouses.Add(new SelectListItem {
                    Text = warehouse.Name, Value = warehouse.Id.ToString(), Selected = (selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id)
                });
            }
            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem {
                    Text = sm.Name, Value = sm.Id.ToString(), Selected = (selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id)
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            var countries = _countryService.GetAllCountries(showHidden: true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString(), Selected = (selectedCountry != null && c.Id == selectedCountry.Id)
                });
            }
            //states
            var states = selectedCountry != null?_stateProvinceService.GetStateProvincesByCountryId(selectedCountry.Id, showHidden : true).ToList() : new List <StateProvince>();

            model.AvailableStates.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var s in states)
            {
                model.AvailableStates.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString(), Selected = (selectedState != null && s.Id == selectedState.Id)
                });
            }

            return(View("~/Plugins/Shipping.ByWeight/Views/EditPopup.cshtml", model));
        }
        //edit
        public async Task <IActionResult> EditPopup(string id)
        {
            var sbw = await _shippingByWeightService.GetById(id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            var model = new ShippingByWeightModel
            {
                Id                       = sbw.Id,
                StoreId                  = sbw.StoreId,
                WarehouseId              = sbw.WarehouseId,
                CountryId                = sbw.CountryId,
                StateProvinceId          = sbw.StateProvinceId,
                Zip                      = sbw.Zip,
                ShippingMethodId         = sbw.ShippingMethodId,
                From                     = sbw.From,
                To                       = sbw.To,
                AdditionalFixedCost      = sbw.AdditionalFixedCost,
                PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal,
                RatePerWeightUnit        = sbw.RatePerWeightUnit,
                LowerWeightLimit         = sbw.LowerWeightLimit,
                PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,
                BaseWeightIn             = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name
            };

            var shippingMethods = await _shippingMethodService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            var selectedStore = await _storeService.GetStoreById(sbw.StoreId);

            var selectedWarehouse = await _warehouseService.GetWarehouseById(sbw.WarehouseId);

            var selectedShippingMethod = await _shippingMethodService.GetShippingMethodById(sbw.ShippingMethodId);

            var selectedCountry = await _countryService.GetCountryById(sbw.CountryId);

            var selectedState = selectedCountry?.StateProvinces.FirstOrDefault(x => x.Id == sbw.StateProvinceId);

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var store in await _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Shortcut, Value = store.Id.ToString(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }
            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var warehouse in await _warehouseService.GetAllWarehouses())
            {
                model.AvailableWarehouses.Add(new SelectListItem {
                    Text = warehouse.Name, Value = warehouse.Id.ToString(), Selected = (selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id)
                });
            }
            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem {
                    Text = sm.Name, Value = sm.Id.ToString(), Selected = (selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id)
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            var countries = await _countryService.GetAllCountries(showHidden : true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString(), Selected = (selectedCountry != null && c.Id == selectedCountry.Id)
                });
            }
            //states
            var states = selectedCountry != null ? await _countryService.GetStateProvincesByCountryId(selectedCountry.Id, showHidden : true) : new List <StateProvince>();

            model.AvailableStates.Add(new SelectListItem {
                Text = "*", Value = ""
            });
            foreach (var s in states)
            {
                model.AvailableStates.Add(new SelectListItem {
                    Text = s.Name, Value = s.Id.ToString(), Selected = (selectedState != null && s.Id == selectedState.Id)
                });
            }

            return(View(model));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> AddPopup()
        {
            var model = new ShippingByWeightModel();

            model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode;
            model.BaseWeightIn             = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name;
            model.To = 1000000;

            var shippingMethods = await _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            //stores
            model.AvailableStores.Add(new SelectListItem {
                Text = "*", Value = " "
            });
            foreach (var store in await _storeService.GetAllStores())
            {
                model.AvailableStores.Add(new SelectListItem {
                    Text = store.Name, Value = store.Id.ToString()
                });
            }
            //warehouses
            model.AvailableWarehouses.Add(new SelectListItem {
                Text = "*", Value = " "
            });
            foreach (var warehouses in await _shippingService.GetAllWarehouses())
            {
                model.AvailableWarehouses.Add(new SelectListItem {
                    Text = warehouses.Name, Value = warehouses.Id.ToString()
                });
            }
            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem {
                    Text = sm.Name, Value = sm.Id.ToString()
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem {
                Text = "*", Value = " "
            });
            var countries = await _countryService.GetAllCountries(showHidden : true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem {
                    Text = c.Name, Value = c.Id.ToString()
                });
            }
            //states
            model.AvailableStates.Add(new SelectListItem {
                Text = "*", Value = " "
            });

            return(View("~/Plugins/Shipping.ByWeight/Views/AddPopup.cshtml", model));
        }
Exemplo n.º 25
0
        public ActionResult Configure()
        {
            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            var model = new ShippingByWeightListModel();

            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem()
                {
                    Text = sm.Name, Value = sm.Id.ToString()
                });
            }


            model.AvailableCountries.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            var countries = _countryService.GetAllCountries(true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem()
                {
                    Text = c.Name, Value = c.Id.ToString()
                });
            }
            model.LimitMethodsToCreated    = _shippingByWeightSettings.LimitMethodsToCreated;
            model.CalculatePerWeightUnit   = _shippingByWeightSettings.CalculatePerWeightUnit;
            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;

            model.Records = _shippingByWeightService.GetAll()
                            .Select(x =>
            {
                var m = new ShippingByWeightModel()
                {
                    Id = x.Id,
                    ShippingMethodId = x.ShippingMethodId,
                    CountryId        = x.CountryId,
                    From             = x.From,
                    To                       = x.To,
                    UsePercentage            = x.UsePercentage,
                    ShippingChargePercentage = x.ShippingChargePercentage,
                    ShippingChargeAmount     = x.ShippingChargeAmount,
                };
                var shippingMethodId = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethodId != null) ? shippingMethodId.Name : "Unavailable";
                if (x.CountryId > 0)
                {
                    var c         = _countryService.GetCountryById(x.CountryId);
                    m.CountryName = (c != null) ? c.Name : "Unavailable";
                }
                else
                {
                    m.CountryName = "*";
                }

                return(m);
            })
                            .ToList();

            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.Configure", model));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> RatesList(DataSourceRequest command)
        {
            var records = await _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);

            var sbwModel = new List <ShippingByWeightModel>();

            foreach (var x in records)
            {
                var m = new ShippingByWeightModel {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    WarehouseId              = x.WarehouseId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    AdditionalFixedCost      = x.AdditionalFixedCost,
                    PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = x.RatePerWeightUnit,
                    LowerWeightLimit         = x.LowerWeightLimit,
                };
                //shipping method
                var shippingMethod = await _shippingService.GetShippingMethodById(x.ShippingMethodId);

                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                //store
                var store = await _storeService.GetStoreById(x.StoreId);

                m.StoreName = (store != null) ? store.Shortcut : "*";
                //warehouse
                var warehouse = await _shippingService.GetWarehouseById(x.WarehouseId);

                m.WarehouseName = (warehouse != null) ? warehouse.Name : "*";
                //country
                var c = await _countryService.GetCountryById(x.CountryId);

                m.CountryName = (c != null) ? c.Name : "*";
                //state
                var s = await _stateProvinceService.GetStateProvinceById(x.StateProvinceId);

                m.StateProvinceName = (s != null) ? s.Name : "*";
                //zip
                m.Zip = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";


                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.From"), m.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.To"), m.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit"), m.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit"), m.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal"), m.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                m.DataHtml = htmlSb.ToString();

                sbwModel.Add(m);
            }
            var gridModel = new DataSourceResult {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }
Exemplo n.º 27
0
        //edit
        public ActionResult EditPopup(int id)
        {
            var sbw = _shippingByWeightService.GetById(id);

            if (sbw == null)
            {
                //No record found with the specified id
                return(RedirectToAction("Configure"));
            }

            var model = new ShippingByWeightModel()
            {
                Id                       = sbw.Id,
                CountryId                = sbw.CountryId,
                StateProvinceId          = sbw.StateProvinceId,
                Zip                      = sbw.Zip,
                ShippingMethodId         = sbw.ShippingMethodId,
                From                     = sbw.From,
                To                       = sbw.To,
                AdditionalFixedCost      = sbw.AdditionalFixedCost,
                PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal,
                RatePerWeightUnit        = sbw.RatePerWeightUnit,
                LowerWeightLimit         = sbw.LowerWeightLimit,
                PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                BaseWeightIn             = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name
            };

            var shippingMethods = _shippingService.GetAllShippingMethods();

            if (shippingMethods.Count == 0)
            {
                return(Content("No shipping methods can be loaded"));
            }

            var selectedShippingMethod = _shippingService.GetShippingMethodById(sbw.ShippingMethodId);
            var selectedCountry        = _countryService.GetCountryById(sbw.CountryId);
            var selectedState          = _stateProvinceService.GetStateProvinceById(sbw.StateProvinceId);

            //shipping methods
            foreach (var sm in shippingMethods)
            {
                model.AvailableShippingMethods.Add(new SelectListItem()
                {
                    Text = sm.Name, Value = sm.Id.ToString(), Selected = (selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id)
                });
            }
            //countries
            model.AvailableCountries.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            var countries = _countryService.GetAllCountries(true);

            foreach (var c in countries)
            {
                model.AvailableCountries.Add(new SelectListItem()
                {
                    Text = c.Name, Value = c.Id.ToString(), Selected = (selectedCountry != null && c.Id == selectedCountry.Id)
                });
            }
            //states
            var states = selectedCountry != null?_stateProvinceService.GetStateProvincesByCountryId(selectedCountry.Id, true).ToList() : new List <StateProvince>();

            model.AvailableStates.Add(new SelectListItem()
            {
                Text = "*", Value = "0"
            });
            foreach (var s in states)
            {
                model.AvailableStates.Add(new SelectListItem()
                {
                    Text = s.Name, Value = s.Id.ToString(), Selected = (selectedState != null && s.Id == selectedState.Id)
                });
            }

            return(View("Nop.Plugin.Shipping.ByWeight.Views.ShippingByWeight.EditPopup", model));
        }