示例#1
0
        public ActionResult Wording(FormCollection form, EditTranslationDto editTranslationDto, bool?addNew)
        {
            var translationDto = editTranslationDto.TranslationDto;

            translationDto.Key = translationDto.Key.Trim();

            var translation = LanguageHelper.GetBaseTranslationDtoByKey(translationDto.Key);

            if (translation != null)
            {
                //-----when we are trying to add new key that is already in use.
                if (addNew == true)
                {
                    ViewBag.Notifications = "Such key is already in use.";

                    return(View(translation));
                }

                LanguageHelper.SaveTranslationDto(translationDto, TranslationsTypeEnum.Base);
            }
            else
            {
                var translationWithOldKey = LanguageHelper.GetBaseTranslationDtoByKey(editTranslationDto.OldKey);
                if (translationWithOldKey != null && translationWithOldKey.IsRemovable)
                {
                    LanguageHelper.DeleteTranslation(editTranslationDto.OldKey, TranslationsTypeEnum.Base);
                }
                LanguageHelper.SaveTranslationDto(translationDto, TranslationsTypeEnum.Base);
            }

            ViewBag.Notifications = "Saved...";

            return(View(translationDto));
        }
示例#2
0
        public ActionResult DeleteTranslation(string key)
        {
            LanguageHelper.DeleteTranslation(key, TranslationsTypeEnum.Base);

            TempData["Notifications"] = $"Deleted translation with key {key}.";

            return(RedirectToAction("Index"));
        }
示例#3
0
 public void DeleteTranslations(string key)
 {
     LanguageHelper.DeleteTranslation(LanguageEnum.Russian, key, TranslationsTypeEnum.Politicians);
     LanguageHelper.DeleteTranslation(LanguageEnum.Ukrainian, key, TranslationsTypeEnum.Politicians);
 }