예제 #1
0
 public LanguageObject SaveLanguage(LanguageObject language)
 {
     if (language.LanguageId > 0) // Update
     {
         string sql = @"
             UPDATE  lu_Language
             SET     Language = @Language,
                     Active = @Active
             WHERE   LanguageId = @LanguageId";
         Config.Conn.Execute(sql, language);
     }
     else
     {
         string sql = @"
             INSERT INTO lu_Language (
                 Language,
                 Active
             )
             VALUES (
                 @Language,
                 @Active
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
         language.LanguageId = Config.Conn.Query <int>(sql, language).Single();
     }
     return(language);
 }
예제 #2
0
 public bool DeleteLanguage(LanguageObject language)
 {
     try
     {
         Config.Conn.Execute("DELETE FROM lu_Language WHERE LanguageId = @LanguageId", language);
     }
     catch { return(false); }
     return(true);
 }
예제 #3
0
        public static List <LanguageObject> GetLanguages(bool enabledOnly = false, int?requiredId = null)
        {
            var cache = HttpContext.Current.Cache;
            List <LanguageObject> data = (List <LanguageObject>)cache[LanguageKey];

            if (data == null)
            {
                data = LanguageObject.GetLanguages();
                cache.Insert(LanguageKey, data, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration);
            }
            return(data.Where(n => (!enabledOnly || n.Active || (requiredId.HasValue && n.LanguageId == requiredId.Value))).ToList());
        }