コード例 #1
0
        public async Task <IActionResult> AddPopup(ShippingByWeightModel model)
        {
            if (!await _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
            };
            await _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            ViewBag.RefreshPage = true;

            return(View("~/Plugins/Shipping.ByWeight/Views/AddPopup.cshtml", model));
        }
コード例 #2
0
        public ActionResult AddPopup(string btnId, string formId, ShippingByWeightModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var sbw = new ShippingByWeightRecord()
            {
                StoreId          = model.StoreId,
                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));
        }
コード例 #3
0
        public virtual void UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException("shippingByWeightRecord");
            }

            _sbwRepository.Update(shippingByWeightRecord);
        }
コード例 #4
0
        public virtual void DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException("shippingByWeightRecord");
            }

            _sbwRepository.Delete(shippingByWeightRecord);

            _cacheManager.RemoveByPattern(SHIPPINGBYWEIGHT_PATTERN_KEY);
        }
コード例 #5
0
        public virtual async Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException("shippingByWeightRecord");
            }

            await _sbwRepository.DeleteAsync(shippingByWeightRecord);

            await _cacheManager.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);
        }
コード例 #6
0
        public virtual async Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException(nameof(shippingByWeightRecord));
            }

            await _sbwRepository.UpdateAsync(shippingByWeightRecord);

            await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);
        }
コード例 #7
0
        public virtual async Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)
        {
            if (shippingByWeightRecord == null)
            {
                throw new ArgumentNullException("shippingByWeightRecord");
            }

            await _sbwRepository.InsertAsync(shippingByWeightRecord);

            _cacheManager.RemoveByPattern(SHIPPINGBYWEIGHT_PATTERN_KEY);
        }
コード例 #8
0
        public ActionResult AddShippingRate(ShippingByWeightListModel model)
        {
            var sbw = new ShippingByWeightRecord()
            {
                ShippingMethodId = model.AddShippingMethodId,
                CountryId        = model.AddCountryId,
                StateProvinceId  = model.AddStateProvinceId,
                Zip                      = model.AddZip,
                From                     = model.AddFrom,
                To                       = model.AddTo,
                UsePercentage            = model.AddUsePercentage,
                ShippingChargeAmount     = model.AddShippingChargeAmount,
                ShippingChargePercentage = model.AddShippingChargePercentage
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            return(Json(new { Result = true }));
        }
コード例 #9
0
        public ActionResult AddShippingByWeightRecord(ShippingByWeightListModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            var sbw = new ShippingByWeightRecord()
            {
                ShippingMethodId = model.AddShippingMethodId,
                CountryId        = model.AddCountryId,
                From             = model.AddFrom,
                To                       = model.AddTo,
                UsePercentage            = model.AddUsePercentage,
                ShippingChargeAmount     = model.AddShippingChargeAmount,
                ShippingChargePercentage = model.AddShippingChargePercentage
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            return(Configure());
        }
コード例 #10
0
        public virtual ShippingByWeightRecord FindRecord(int shippingMethodId, int countryId, decimal weight)
        {
            ShippingByWeightRecord result = null;
            var query = from sbw in _sbwRepository.Table
                        where sbw.ShippingMethodId == shippingMethodId && weight >= sbw.From && weight <= sbw.To
                        orderby sbw.CountryId, sbw.ShippingMethodId, sbw.From
            select sbw;

            var existingRecords = query.ToList();

            //filter by country
            foreach (var sbw in existingRecords)
            {
                if (countryId == sbw.CountryId)
                {
                    result = sbw;
                }
            }

            foreach (var sbw in existingRecords)
            {
                if (sbw.CountryId == 0)
                {
                    result = sbw;
                }
            }

            if (result != null)
            {
                if (result.CurrencyId.HasValue)
                {
                    var cur = _currencyService.GetCurrencyById(result.CurrencyId.Value);
                    result.ShippingChargeAmount = _currencyService.ConvertToPrimaryStoreCurrency(result.ShippingChargeAmount, cur);
                }
            }

            return(result);
        }
コード例 #11
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));
        }
コード例 #12
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(model));
        }
コード例 #13
0
        public ActionResult AddShippingByWeightRecord(ShippingByWeightListModel model)
        {
            var sbw = new ShippingByWeightRecord()
            {
                StoreId          = model.AddStoreId,
                ShippingMethodId = model.AddShippingMethodId,
                CountryId        = model.AddCountryId,
                Zip = model.AddZip,
                //StateProvinceId = 0,
                From                     = model.AddFrom,
                To                       = model.AddTo,
                UsePercentage            = model.AddUsePercentage,
                ShippingChargeAmount     = model.AddShippingChargeAmount,
                ShippingChargePercentage = model.AddShippingChargePercentage,
                SmallQuantitySurcharge   = model.SmallQuantitySurcharge,
                SmallQuantityThreshold   = model.SmallQuantityThreshold,
            };

            _shippingByWeightService.InsertShippingByWeightRecord(sbw);

            NotifySuccess(T("Plugins.Shipping.ByWeight.AddNewRecord.Success"));

            return(Json(new { Result = true }));
        }