Example #1
0
 public bool DeleteTranslation(Translation entity)
 {
     if (entity == null) return false;
     _unitOfWork.TranslationRepository.Delete(entity);
     _unitOfWork.Save();
     return true;
 }
Example #2
0
 public ActionResult Save( Translation model)
 {
     Translation translation = _translationService.FindById(model.TranslationID);
     translation.Phrase = translation.Phrase.Trim();
     translation.TranslatedText = model.TranslatedText.Trim();
     _translationService.AddTranslation(translation);
     return RedirectToAction("Index");
 }
Example #3
0
        public string GetForText(string text, string langauge)
        {
            var Trans = _unitOfWork.TranslationRepository.FindBy(t => t.Phrase.Trim() == text.Trim() && t.LanguageCode == langauge).FirstOrDefault();

            var Translation1 = Trans !=null ? Trans.TranslatedText : null;

            if (Translation1 == null)
            {
                Translation translation = new Translation();
                translation.LanguageCode = langauge;
                translation.Phrase = text.Trim();
                translation.TranslatedText = text.Trim();
                _unitOfWork.TranslationRepository.Add(translation);
                _unitOfWork.Save();

                Translation english = null;
                if (langauge != "en")
                {
                    english = _unitOfWork.TranslationRepository.FindBy(t => t.Phrase == text && t.LanguageCode == "en").FirstOrDefault();
                }
                if (english == null)
                {
                    translation = new Translation();
                    translation.LanguageCode = "en";
                    translation.Phrase = translation.TranslatedText = text.Trim();
                    _unitOfWork.TranslationRepository.Add(translation);
                    _unitOfWork.Save();
                }
                else
                {
                    return english.TranslatedText;
                }
                return text;
            }
            return Translation1;
        }
Example #4
0
 public bool EditTranslation(Translation entity)
 {
     _unitOfWork.TranslationRepository.Edit(entity);
     _unitOfWork.Save();
     return true;
 }