public async Task <ActionResult> UpdateCountrySetting(CountrySettingViewModel model) { if (!ModelState.IsValid) { return(View("Error")); } try { var item = Mapper.Map <CountrySettingViewModel, CountrySettingDTO>(model); _countrySettingsService.AddItem(item); _countrySettingsService.Commit(); _countrySettingsService.Dispose(); var userName = User.Identity.Name; Logger.Log.Info($"{userName}: CreateCountrySetting {model.CountryId} "); TempData["Success"] = Resources.Messages.SettingsCreateSuccess; return(RedirectToAction("CountrySettings")); } catch (Exception ex) { var userName = User.Identity.Name; Logger.Log.Error($"{userName}: CreateProduct() {ex.Message} "); @ViewBag.Error = ex.Message; return(View("Error")); } }
public ActionResult EditCountrySetting(int?countryId) { var _countryId = countryId ?? 0; if (_countryId == 0) { @ViewBag.Error = @Resources.ErrorMessages.NoCountryId; return(View("Error")); } try { var countrySetting = _countrySettingsService.GetItem(_countryId); var model = new CountrySettingViewModel() { CountryId = _countryId, Country = Mapper.Map <Country, CountryDTO>(countrySetting.Country), EanActive = countrySetting.EanActive, GtinActive = countrySetting.GtinActive }; return(View(model)); } catch (Exception e) { var userName = User.Identity.Name; Logger.Log.Error($"{userName}: CreateCountrySetting() {e.Message} "); @ViewBag.Error = e.Message; return(View("Error")); } }