Пример #1
0
        [HttpPost]  //TODO: Determine how to add back AdminAntiForgery
        public IActionResult GetRate(int id)
        {
            var shippingByTotalRecord = _shippingByTotalService.GetShippingByTotalRecordById(id);

            if (shippingByTotalRecord != null)
            {
                var model = new ShippingByTotalModel
                {
                    Id                       = shippingByTotalRecord.Id,
                    ZipPostalCode            = shippingByTotalRecord.ZipPostalCode,
                    DisplayOrder             = shippingByTotalRecord.DisplayOrder,
                    From                     = shippingByTotalRecord.From,
                    To                       = shippingByTotalRecord.To,
                    UsePercentage            = shippingByTotalRecord.UsePercentage,
                    ShippingChargePercentage = shippingByTotalRecord.ShippingChargePercentage,
                    ShippingChargeAmount     = shippingByTotalRecord.ShippingChargeAmount,
                    ShippingMethodId         = shippingByTotalRecord.ShippingMethodId,
                    StoreId                  = shippingByTotalRecord.StoreId,
                    WarehouseId              = shippingByTotalRecord.WarehouseId,
                    StateProvinceId          = shippingByTotalRecord.StateProvinceId,
                    CountryId                = shippingByTotalRecord.CountryId
                };

                return(Json(model));
            }
            return(new NullJsonResult());
        }
        public IActionResult RateUpdate(ShippingByTotalModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            var shippingByTotalRecord = _shippingByTotalService.GetShippingByTotalRecordById(model.Id);

            shippingByTotalRecord.ZipPostalCode            = model.ZipPostalCode == "*" ? null : model.ZipPostalCode;
            shippingByTotalRecord.DisplayOrder             = model.DisplayOrder;
            shippingByTotalRecord.From                     = model.From;
            shippingByTotalRecord.To                       = model.To;
            shippingByTotalRecord.UsePercentage            = model.UsePercentage;
            shippingByTotalRecord.ShippingChargePercentage = model.UsePercentage ? model.ShippingChargePercentage : 0;
            shippingByTotalRecord.ShippingChargeAmount     = !model.UsePercentage ? model.ShippingChargeAmount : 0;
            shippingByTotalRecord.ShippingMethodId         = model.ShippingMethodId;
            shippingByTotalRecord.StoreId                  = model.StoreId;
            shippingByTotalRecord.WarehouseId              = model.WarehouseId;
            shippingByTotalRecord.StateProvinceId          = model.StateProvinceId;
            shippingByTotalRecord.CountryId                = model.CountryId;
            _shippingByTotalService.UpdateShippingByTotalRecord(shippingByTotalRecord);

            return(new NullJsonResult());
        }
        public ActionResult RateUpdate(ShippingByTotalModel model, GridCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(new JsonResult {
                    Data = "error"
                });
            }

            var shippingByTotalRecord = _shippingByTotalService.GetShippingByTotalRecordById(model.Id);

            shippingByTotalRecord.Zip                      = model.Zip == "*" ? null : model.Zip;
            shippingByTotalRecord.From                     = model.From;
            shippingByTotalRecord.To                       = model.To;
            shippingByTotalRecord.UsePercentage            = model.UsePercentage;
            shippingByTotalRecord.ShippingChargeAmount     = model.ShippingChargeAmount;
            shippingByTotalRecord.ShippingChargePercentage = model.ShippingChargePercentage;
            shippingByTotalRecord.BaseCharge               = model.BaseCharge;
            shippingByTotalRecord.MaxCharge                = model.MaxCharge;
            _shippingByTotalService.UpdateShippingByTotalRecord(shippingByTotalRecord);

            return(RatesList(command));
        }