public ActionResult EditCountry(int id, LocationsCountriesEditViewModel model) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage Countries"))) { return(new HttpUnauthorizedResult()); } var record = _locationService.GetCountry(model.Id); if (record == null) { return(new HttpNotFoundResult()); } if (ModelState.IsValid) { record.Name = model.Name; record.IsoCode = model.IsoCode; record.AddressFormat = model.AddressFormat; record.Enabled = model.Enabled; if (_shippingService != null) { record.ShippingZoneRecord = _shippingService.GetZone(model.ShippingZoneId); } Services.Notifier.Information(T("Country {0} successfully updated.", model.Name)); } model.ShippingZones = _shippingService != null?_shippingService.GetZones() : new List <ShippingZoneRecord>(); return(View(model)); }
public ActionResult EditCountry(int id) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage Countries"))) { return(new HttpUnauthorizedResult()); } var record = _locationService.GetCountry(id); if (record == null) { return(new HttpNotFoundResult()); } var model = new LocationsCountriesEditViewModel() { Name = record.Name, IsoCode = record.IsoCode, AddressFormat = record.AddressFormat, Enabled = record.Enabled, ShippingZoneId = record.ShippingZoneRecord != null ? record.ShippingZoneRecord.Id : 0 }; model.ShippingZones = _shippingService != null?_shippingService.GetZones() : new List <ShippingZoneRecord>(); return(View(model)); }