Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public ActionResult Wording(string key)
        {
            var model = new TranslationDto()
            {
                IsRemovable  = true,
                Translations = new System.Collections.Generic.Dictionary <LanguageEnum, string>
                {
                    { LanguageEnum.Russian, "" },
                    { LanguageEnum.Ukrainian, "" }
                }
            };

            if (string.IsNullOrEmpty(key))
            {
                ViewBag.AddNew = true;
                return(View(model));
            }

            var translation = LanguageHelper.GetBaseTranslationDtoByKey(key);

            if (translation != null)
            {
                return(View(translation));
            }

            return(Redirect("Error"));
        }