コード例 #1
0
 //[HttpPost]
 public ActionResult Create(Translation.Models.CATSEntities translation)
 {
     try
     {
         using (var db = new CATSEntities())
         {
             //db.Translations.add(translation);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
コード例 #2
0
        public string GetForText(string text, string langauge)
        {
            var converted = (from v in db.Translations
                             where v.Phrase.Trim() == text.Trim() && v.LanguageCode == langauge
                             select v.TranslatedText).FirstOrDefault();

            if (converted == null)
            {
                // try to see if we can find this phrase in english
                Translation.Models.Translation translation = new Translation.Models.Translation();
                translation.LanguageCode   = langauge;
                translation.Phrase         = text.Trim();
                translation.TranslatedText = text.Trim();
                this.Add(translation);

                Translation.Models.Translation english = null;
                if (langauge != "en")
                {
                    english = (from v in db.Translations
                               where v.LanguageCode == "en" && v.Phrase == text
                               select v).FirstOrDefault();
                }

                // Have an entry for it in the database for english
                if (english == null)
                {
                    translation = new Translation.Models.Translation();
                    translation.LanguageCode = "en";
                    translation.Phrase       = translation.TranslatedText = text.Trim();
                    this.Add(translation);
                }
                else
                {
                    return(english.TranslatedText);
                }
                return(text);
            }
            return(converted);
        }
コード例 #3
0
        public string GetForText(string text, string langauge)
        {
            var converted = (from v in db.Translations
                               where v.Phrase.Trim() == text.Trim() && v.LanguageCode == langauge
                               select v.TranslatedText).FirstOrDefault();
            if(converted == null)
            {
                // try to see if we can find this phrase in english
                Translation.Models.Translation translation = new Translation.Models.Translation();
                translation.LanguageCode = langauge;
                translation.Phrase = text.Trim();
                translation.TranslatedText = text.Trim();
                this.Add(translation);

                Translation.Models.Translation english = null;
                if(langauge != "en")
                {
                    english = (from v in db.Translations
                                   where v.LanguageCode == "en" && v.Phrase == text
                                   select v).FirstOrDefault();

                }

                // Have an entry for it in the database for english
                if(english == null)
                {
                    translation = new Translation.Models.Translation();
                    translation.LanguageCode = "en";
                    translation.Phrase = translation.TranslatedText = text.Trim();
                    this.Add(translation);
                }
                else
                {
                    return english.TranslatedText;
                }
                return text;
            }
            return converted;
        }
コード例 #4
0
 public bool Add(Translation.Models.Translation entity)
 {
     db.SaveChanges();
     return(true);
 }
コード例 #5
0
 public bool Add(Translation.Models.Translation entity)
 {
     db.SaveChanges();
     return true;
 }