示例#1
0
        public ActionResult EditRateByDistrictPopup(string btnId, string formId, ShippingByDistrictModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var sbd = _shippingByDistrictService.GetById(model.Id);

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

            sbd.StoreId             = model.StoreId;
            sbd.CountryId           = model.CountryId;
            sbd.StateProvinceId     = model.StateProvinceId;
            sbd.Zip                 = model.Zip == "*" ? null : model.Zip;
            sbd.ShippingMethodId    = model.ShippingMethodId;
            sbd.AdditionalFixedCost = model.AdditionalFixedCost;
            _shippingByDistrictService.UpdateShippingByDistrictRecord(sbd);

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

            return(View("~/Plugins/Shipping.RateByDistrict/Views/EditRateByDistrictPopup.cshtml", model));
        }
示例#2
0
        public ActionResult AddRateByDistrictPopup(string btnId, string formId, ShippingByDistrictModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var sbd = new ShippingByDistrictRecord
            {
                StoreId             = model.StoreId,
                CountryId           = model.CountryId,
                StateProvinceId     = model.StateProvinceId,
                Zip                 = model.Zip == "*" ? null : model.Zip,
                ShippingMethodId    = model.ShippingMethodId,
                AdditionalFixedCost = model.AdditionalFixedCost,
            };

            _shippingByDistrictService.InsertShippingByDistrictRecord(sbd);

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

            return(View("~/Plugins/Shipping.RateByDistrict/Views/AddRateByDistrictPopup.cshtml", model));
        }
示例#3
0
        public ActionResult AddRateByDistrictPopup()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var model = new ShippingByDistrictModel
            {
                PrimaryStoreCurrencyCode =
                    _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
            };

            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()
                });
            }
            //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.RateByDistrict/Views/AddRateByDistrictPopup.cshtml", model));
        }
示例#4
0
        public ActionResult RateByDistrictList(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(ErrorForKendoGridJson("Access denied"));
            }

            var records  = _shippingByDistrictService.GetAll(command.Page - 1, command.PageSize);
            var sbdModel = records.Select(x =>
            {
                var m = new ShippingByDistrictModel
                {
                    Id                  = x.Id,
                    StoreId             = x.StoreId,
                    ShippingMethodId    = x.ShippingMethodId,
                    CountryId           = x.CountryId,
                    AdditionalFixedCost = x.AdditionalFixedCost,
                };
                //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 : "*";
                //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.RateByDistrict.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);

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

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

            return(Json(gridModel));
        }
示例#5
0
        public ActionResult EditRateByDistrictPopup(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl }));
            }

            var sbd = _shippingByDistrictService.GetById(id);

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

            var model = new ShippingByDistrictModel
            {
                Id                       = sbd.Id,
                StoreId                  = sbd.StoreId,
                CountryId                = sbd.CountryId,
                StateProvinceId          = sbd.StateProvinceId,
                Zip                      = sbd.Zip,
                ShippingMethodId         = sbd.ShippingMethodId,
                AdditionalFixedCost      = sbd.AdditionalFixedCost,
                PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
            };

            var shippingMethods = _shippingService.GetAllShippingMethods();

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

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

            //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(), Selected = (selectedStore != null && store.Id == selectedStore.Id)
                });
            }
            //warehouses
            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(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 = "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("~/Plugins/Shipping.RateByDistrict/Views/EditRateByDistrictPopup.cshtml", model));
        }