protected override ActionResult Update() { try { if (ModelState.IsValid) { using (var scope = new UnitOfWorkScope()) { Localization currentLocalization = _repository.Get(Convert.ToInt32(GridModel.Id)); if (currentLocalization == null) { throw new DuplicateKeyException(); } currentLocalization.SetValue(GridModel.Value); _repository.Update(currentLocalization); scope.Commit(); } return(Json(GridModel)); } } catch (DuplicateKeyException) { ModelState.AddModelError(string.Empty, string.Format("This type of Localization {0} already exists in the system.", GridModel.Key)); } throw CreateModelException(GridModel); }
/// <summary> /// Save language /// </summary> /// <param name="language"></param> public void Save(Language language) { try { language = SanitizeLanguage(language); _localizationRepository.Update(language); } catch (Exception ex) { throw new ApplicationException(string.Format("Unable to save language: {0}", ex.Message), ex); } }
public async Task Modify(LocalizationEntity localEntity) { var document = await _localizationRepository.GetByCode(localEntity.DisplayKey); if (document == null) { await _localizationRepository.Insert(localEntity); } else { await _localizationRepository.Update(localEntity); } }
public bool Update(LocalizationEditModel entity) { var localization = _repository.Get(entity.Id); if (localization == null) { throw new Exception(LOCALIZATION_LOCALIZATIONCLASS_ENTITY_NOT_FOUND + entity.Id); } var language = _languageRepository.Get(entity.LanguageId); if (language == null) { throw new Exception(LOCALIZATION_LOCALIZATIONCLASS_NOT_FOUND); } localization.LocalizationKey = entity.LocalizationKey; localization.LocalizationValue = entity.LocalizationValue; localization.Language = language; return(_repository.Update(localization)); }