Пример #1
0
        /// <summary>
        /// Creates a new language given the culture code - ie. da-dk  (denmark)
        /// </summary>
        /// <param name="cultureCode">Culturecode of the language</param>
        public static void MakeNew(string cultureCode)
        {
            lock (Locker)
            {
                var culture = GetCulture(cultureCode);
                if (culture != null)
                {
                    //insert it
                    SqlHelper.ExecuteNonQuery(
                        "insert into umbracoLanguage (languageISOCode) values (@CultureCode)",
                        SqlHelper.CreateParameter("@CultureCode", cultureCode));

                    InvalidateCache();

                    //get it's id
                    var newId = SqlHelper.ExecuteScalar <int>("SELECT MAX(id) FROM umbracoLanguage WHERE languageISOCode=@cultureCode", SqlHelper.CreateParameter("@cultureCode", cultureCode));

                    //load it and raise events
                    using (var dr = SqlHelper.ExecuteReader(string.Format("{0} where id = {1}", m_SQLOptimizedGetAll, newId)))
                    {
                        while (dr.Read())
                        {
                            var ct = new Language();
                            ct.PopulateFromReader(dr);
                            ct.OnNew(new NewEventArgs());
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new language given the culture code - ie. da-dk  (denmark)
        /// </summary>
        /// <param name="cultureCode">Culturecode of the language</param>
        public static void MakeNew(string cultureCode)
        {
            var culture = GetCulture(cultureCode);

            if (culture != null)
            {
                //insert it
                var lang = new Umbraco.Core.Models.Language(cultureCode)
                {
                    CultureName = culture.DisplayName
                };
                ApplicationContext.Current.Services.LocalizationService.Save(lang);
                var ct = new Language(lang);
                ct.OnNew(new NewEventArgs());
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a new language given the culture code - ie. da-dk  (denmark)
        /// </summary>
        /// <param name="cultureCode">Culturecode of the language</param>
        public static void MakeNew(string cultureCode)
        {
            lock (Locker)
            {
                var culture = GetCulture(cultureCode);
                if (culture != null)
                {
                    //insert it
                    SqlHelper.ExecuteNonQuery(
                        "insert into umbracoLanguage (languageISOCode) values (@CultureCode)",
                        SqlHelper.CreateParameter("@CultureCode", cultureCode));

                    //get it's id
                    var newId = SqlHelper.ExecuteScalar<int>("SELECT MAX(id) FROM umbracoLanguage WHERE languageISOCode=@cultureCode", SqlHelper.CreateParameter("@cultureCode", cultureCode));

                    //load it and raise events
                    using (var dr = SqlHelper.ExecuteReader(string.Format("{0} where id = {1}", m_SQLOptimizedGetAll, newId)))
                    {
                        while (dr.Read())
                        {

                            var ct = new Language();
                            ct.PopulateFromReader(dr);
                            ct.OnNew(new NewEventArgs());
                        }
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Creates a new language given the culture code - ie. da-dk  (denmark)
 /// </summary>
 /// <param name="cultureCode">Culturecode of the language</param>
 public static void MakeNew(string cultureCode)
 {
     lock (Locker)
     {
         var culture = GetCulture(cultureCode);
         if (culture != null)
         {
             //insert it
             var newId = ApplicationContext.Current.DatabaseContext.Database.Insert(new LanguageDto { IsoCode = cultureCode });
             var ct = new Language { _id = Convert.ToInt32(newId), _cultureAlias = cultureCode };
             ct.UpdateNames();
             ct.OnNew(new NewEventArgs());
              
         }
     }
 }