Esempio n. 1
0
 private static void SetOtherNames(Database db, Language language, string[] names, string languageIn, Action <OtherName> onSaved = null, Action <OtherName> onExists = null)
 {
     names.Rest(1, (langName) =>
     {
         OtherName name = OtherName.OneWhere(o => o.LanguageId == language.Id && o.LanguageName == languageIn && o.Value == langName, db);
         if (name == null)
         {
             name              = new OtherName();
             name.Uuid         = Guid.NewGuid().ToString();
             name.LanguageId   = language.Id;
             name.LanguageName = languageIn;
             name.Value        = langName;
             name.Save(db);
             if (onSaved != null)
             {
                 onSaved(name);
             }
         }
         else
         {
             if (onExists != null)
             {
                 onExists(name);
             }
         }
     });
 }
Esempio n. 2
0
 private void OnOtherNameSaved(OtherName name)
 {
     FireEvent(LanguageOtherNameSaved, new LanguageEventArgs {
         OtherName = name
     });
     Logger.AddEntry("Language OtherName saved: \r\n{0}", name.ToJsonSafe().PropertiesToString());
 }
Esempio n. 3
0
        public static Language FindLanguage(string languageIdentifier, Database db)
        {
            Language toLanguage;

            if (languageIdentifier.Length == 2)
            {
                toLanguage = Language.OneWhere(c => c.ISO6391 == languageIdentifier, db);
            }
            else if (languageIdentifier.Length == 3)
            {
                toLanguage = Language.OneWhere(c => c.ISO6392 == languageIdentifier, db);
            }
            else
            {
                toLanguage = Language.OneWhere(c => c.EnglishName == languageIdentifier, db);
                if (toLanguage == null)
                {
                    OtherName otherName = OtherName.FirstOneWhere(c => c.Value == languageIdentifier, db);
                    if (otherName != null)
                    {
                        toLanguage = otherName.LanguageOfLanguageId;
                    }
                }
            }

            return(toLanguage ?? Language.Default);
        }
Esempio n. 4
0
        private static OtherName CreateFromFilter(IQueryFilter filter, Database database = null)
        {
            Database db  = database ?? Db.For <OtherName>();
            var      dao = new OtherName();

            filter.Parameters.Each(p =>
            {
                dao.Property(p.ColumnName, p.Value);
            });
            dao.Save(db);
            return(dao);
        }
Esempio n. 5
0
 public ActionResult Update(Bam.Net.Translation.OtherName dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Esempio n. 6
0
 public ActionResult Delete(long id)
 {
     try
     {
         string msg = "";
         Bam.Net.Translation.OtherName dao = Bam.Net.Translation.OtherName.OneWhere(c => c.KeyColumn == id);
         if (dao != null)
         {
             dao.Delete();
         }
         else
         {
             msg = string.Format("The specified id ({0}) was not found in the table (OtherName)", id);
         }
         return(Json(new { Success = true, Message = msg, Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
Esempio n. 7
0
 private void OnOtherNameExists(OtherName name)
 {
     Logger.AddEntry("Language OtherName exists: \r\n{0}", name.ToJsonSafe().PropertiesToString());
 }
Esempio n. 8
0
 public ActionResult Create(Bam.Net.Translation.OtherName dao)
 {
     return(Update(dao));
 }