public ActionResult AddCountry(LocationsCountriesAddViewModel model) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage Countries"))) { return(new HttpUnauthorizedResult()); } if (ModelState.IsValid) { var record = new LocationsCountryRecord() { Name = model.Name, IsoCode = model.IsoCode, AddressFormat = model.AddressFormat, Enabled = model.Enabled, }; if (_shippingService != null) { record.ShippingZoneRecord = _shippingService.GetZone(model.ShippingZoneId); } _locationService.AddCountry(record); Services.Notifier.Information(T("Country {0} successfully added.", model.Name)); return(RedirectToAction("Index")); } model.ShippingZones = _shippingService != null?_shippingService.GetZones() : new List <ShippingZoneRecord>(); return(View(model)); }
public void SetDefaulCountry(LocationsCountryRecord record) { if (record != null) { SetDefaulCountryId(record.Id); } }
public void BuildCart(IShoppingCartService ShoppingCartService, ShoppingCart Cart) { LocationsStateRecord state = null; LocationsCountryRecord country = null; // Based on user selected location Int32 countryId = ShoppingCartService.GetProperty <int>("CountryId"); if (countryId > 0) { country = _locationsService.GetCountry(countryId); Int32 stateId = ShoppingCartService.GetProperty <int>("StateId"); if (stateId > 0) { state = _locationsService.GetState(stateId); } } else { // Set default country country = _locationsService.GetDefaultCountry(); if (country != null) { ShoppingCartService.SetProperty <int>("CountryId", country.Id); } } Cart.Properties["BillingCountry"] = country; Cart.Properties["BillingState"] = state; Cart.Properties["ShippingCountry"] = country; Cart.Properties["ShippingState"] = state; }
public void DeleteCountry(LocationsCountryRecord record) { foreach (var state in _stateRepository.Fetch(state => state.LocationsCountryRecord == record)) { _stateRepository.Delete(state); } _countryRepository.Delete(record); }
public void Import(XDocument ImportedLocations) { foreach (var xCountry in ImportedLocations.Root.Elements("country")) { var countryIsoCode = xCountry.Attribute("iso_code").Value; var country = _countryRepository.Get(c => c.IsoCode == countryIsoCode); if (country == null) { country = new LocationsCountryRecord() { IsoCode = countryIsoCode, Name = xCountry.Element("name").Value, AddressFormat = xCountry.Element("address_format").Value }; _countryRepository.Create(country); } else { country.Name = xCountry.Element("name").Value; country.AddressFormat = xCountry.Element("address_format").Value; } foreach (var xState in xCountry.Element("states").Elements("state")) { var stateIsoCode = xState.Attribute("iso_code").Value; var state = _stateRepository.Get(s => s.IsoCode == stateIsoCode && s.LocationsCountryRecord.Id == country.Id); if (state == null) { state = new LocationsStateRecord() { IsoCode = stateIsoCode, Name = xState.Element("name").Value, LocationsCountryRecord = country }; _stateRepository.Create(state); } else { state.Name = xState.Element("name").Value; _stateRepository.Update(state); } } } }
public void UpdateCountry(LocationsCountryRecord record) { _countryRepository.Update(record); }
public void AddCountry(LocationsCountryRecord record) { _countryRepository.Create(record); }
public void DeleteCountry(LocationsCountryRecord record) { _countryRepository.Delete(record); }