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 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 void CreateZone(ShippingZoneRecord record) { _zoneRepository.Create(record); }
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 void UpdateZone(ShippingZoneRecord record) { _zoneRepository.Update(record); }
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; }