public ActionResult AddState(LocationsStatesAddViewModel model) { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage States"))) { return(new HttpUnauthorizedResult()); } if (ModelState.IsValid) { var record = new LocationsStateRecord() { Name = model.Name, IsoCode = model.IsoCode, Enabled = model.Enabled, LocationsCountryRecord = _locationService.GetCountry(model.CountryId) }; if (_shippingService != null) { record.ShippingZoneRecord = _shippingService.GetZone(model.ShippingZoneId); } _locationService.AddState(record); Services.Notifier.Information(T("State {0} successfully added.", model.Name)); return(RedirectToAction("States")); } model.Countries = _locationService.GetCountries(); model.ShippingZones = _shippingService != null?_shippingService.GetZones() : new List <ShippingZoneRecord>(); return(View(model)); }
public ActionResult AddState() { if (!Services.Authorizer.Authorize(Permissions.OShopPermissions.ManageShopSettings, T("Not allowed to manage States"))) { return(new HttpUnauthorizedResult()); } var model = new LocationsStatesAddViewModel(); model.ShippingZones = _shippingService != null?_shippingService.GetZones() : new List <ShippingZoneRecord>(); model.Countries = _locationService.GetCountries(); return(View(model)); }