private ShippingOptionRecord GetSuitableOption(int ShippingProviderId, ShippingZoneRecord Zone, IList <Tuple <int, IShippingInfo> > ShippingInfos, Decimal ItemsTotal) { if (Zone == null) { return(null); } return(_optionRepository .Fetch(o => o.ShippingProviderId == ShippingProviderId && o.ShippingZoneRecord == Zone && o.Enabled) .OrderByDescending(o => o.Priority) .Where(o => MeetsContraints(o, ShippingInfos, ItemsTotal)) .FirstOrDefault()); }
public ActionResult Edit(int id, ShippingZoneRecord model) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage shipping zones"))) { return(new HttpUnauthorizedResult()); } if (ModelState.IsValid) { _shippingService.UpdateZone(model); Services.Notifier.Information(T("Country {0} successfully updated.", model.Name)); } return(View(model)); }
public IEnumerable <ShippingProviderOption> GetSuitableProviderOptions(ShippingZoneRecord Zone, IList <Tuple <int, IShippingInfo> > ShippingInfos, Decimal ItemsTotal = 0) { var publishedProviders = _contentManager.Query <ShippingProviderPart>(VersionOptions.Published).List(); List <ShippingProviderOption> suitableProviders = new List <ShippingProviderOption>(); foreach (var provider in publishedProviders) { var option = GetSuitableOption(provider.Id, Zone, ShippingInfos, ItemsTotal); if (option != null) { suitableProviders.Add(new ShippingProviderOption(provider, option)); } } return(suitableProviders); }
public void DeleteZone(ShippingZoneRecord record) { if (record != null) { foreach (var country in _countryRepository.Fetch(c => c.ShippingZoneRecord != null && c.ShippingZoneRecord.Id == record.Id)) { country.ShippingZoneRecord = null; } ; foreach (var state in _stateRepository.Fetch(s => s.ShippingZoneRecord != null && s.ShippingZoneRecord.Id == record.Id)) { state.ShippingZoneRecord = null; } foreach (var option in _optionRepository.Fetch(o => o.ShippingZoneRecord != null && o.ShippingZoneRecord.Id == record.Id)) { option.ShippingZoneRecord = null; } _zoneRepository.Delete(record); } }
public ActionResult StatesBulkSetZone(LocationsStatesIndexViewModel model, IEnumerable <int> itemIds, string returnUrl) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage States"))) { return(new HttpUnauthorizedResult()); } if (itemIds != null) { ShippingZoneRecord zone = null; if (model.BulkZoneId > 0) { zone = _shippingService.GetZone(model.BulkZoneId); if (zone == null) { Services.Notifier.Warning(T("Unknown zone : Unable to update state zones")); return(this.RedirectLocal(returnUrl, () => RedirectToAction("States"))); } } int counter = 0; foreach (int itemId in itemIds) { var state = _locationService.GetState(itemId); if (state != null) { state.ShippingZoneRecord = zone; counter++; } } Services.Notifier.Information(T.Plural("One state zone successfully updated.", "{0} states zones successfully updated.", counter)); } return(this.RedirectLocal(returnUrl, () => RedirectToAction("States"))); }
public void UpdateZone(ShippingZoneRecord record) { _zoneRepository.Update(record); }
public void CreateZone(ShippingZoneRecord record) { _zoneRepository.Create(record); }