public async Task <IActionResult> RateDelete(string id) { var sbw = await _shippingByWeightService.GetById(id); if (sbw != null) { await _shippingByWeightService.DeleteShippingByWeightRecord(sbw); } return(new NullJsonResult()); }
public ActionResult RateDelete(int id, GridCommand command) { var sbw = _shippingByWeightService.GetById(id); if (sbw != null) { _shippingByWeightService.DeleteShippingByWeightRecord(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.ShippingChargeAmount = model.ShippingChargeAmount; sbw.ShippingChargePercentage = model.ShippingChargePercentage; _shippingByWeightService.UpdateShippingByWeightRecord(sbw); return(RatesList(command)); }
public IActionResult RateDelete(string id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(Content("Access denied")); } var sbw = _shippingByWeightService.GetById(id); if (sbw != null) { _shippingByWeightService.DeleteShippingByWeightRecord(sbw); } return(new NullJsonResult()); }
public ActionResult RateDelete(int id, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(Content("Access denied")); } var sbw = _shippingByWeightService.GetById(id); if (sbw != null) { _shippingByWeightService.DeleteShippingByWeightRecord(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)); }
public IActionResult EditRateByWeighPopup(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } 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.Any()) { 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 = "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 model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = "0" }); 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 = "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.FixedOrByWeight/Views/EditRateByWeightPopup.cshtml", model)); }