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); }
/// <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; }