public bool ShippingZoneRemoveArea(long zoneId, string countryIso3, string regionAbbreviation) { Zone z = ShippingZones.Find(zoneId); if (z != null) { if (z.Id == zoneId) { ZoneArea located = null; foreach (ZoneArea a in z.Areas) { if (a.CountryIsoAlpha3 == countryIso3 && a.RegionAbbreviation == regionAbbreviation) { located = a; break; } } if (located != null) { if (z.Areas.Remove(located)) { return(ShippingZones.Update(z)); } } } } return(false); }
public bool ShippingZoneAddArea(long zoneId, string countryIso3, string regionAbbreviation) { Zone z = ShippingZones.Find(zoneId); if (z != null) { if (z.Id == zoneId) { bool exists = false; foreach (ZoneArea a in z.Areas) { if (a.CountryIsoAlpha3 == countryIso3 && a.RegionAbbreviation == regionAbbreviation) { exists = true; break; } } if (!exists) { z.Areas.Add(new ZoneArea() { CountryIsoAlpha3 = countryIso3, RegionAbbreviation = regionAbbreviation }); return(ShippingZones.Update(z)); } } } return(false); }