diff --git a/src/Swastika.Cms.Lib/Services/GlobalConfigurationService.cs b/src/Swastika.Cms.Lib/Services/GlobalConfigurationService.cs index d7035831..54940e85 100644 --- a/src/Swastika.Cms.Lib/Services/GlobalConfigurationService.cs +++ b/src/Swastika.Cms.Lib/Services/GlobalConfigurationService.cs @@ -23,32 +23,26 @@ public class GlobalConfigurationService public string Name { get; set; } public bool IsInit { get; set; } - public string ConnectionString - { - get - { + public string ConnectionString { + get { return _connectionString; } - set - { + set { _connectionString = value; } } private static List _listConfiguration; - public static List ListConfiguration - { - get - { + public static List ListConfiguration { + get { if (_listConfiguration == null) { InitConfigurations(); } return _listConfiguration; } - set - { + set { _listConfiguration = value; } } @@ -71,14 +65,11 @@ public static List ListConfiguration //} private static GlobalConfigurationService _instance; - public static GlobalConfigurationService Instance - { - get - { + public static GlobalConfigurationService Instance { + get { return _instance ?? (_instance = new GlobalConfigurationService()); } - set - { + set { _instance = value; } } @@ -250,7 +241,7 @@ public void InitSWCms() }; isSucceed = isSucceed && theme.SaveModel(true, context, transaction).IsSucceed; - + if (isSucceed) { ConfigurationViewModel config = (ConfigurationViewModel.Repository.GetSingleModel( @@ -377,19 +368,17 @@ public void InitSWCms() if (isSucceed) { - - BECategoryViewModel cate = new BECategoryViewModel( new SiocCategory() + BECategoryViewModel cate = new BECategoryViewModel(new SiocCategory() { Title = "Home", Specificulture = "vi-vn", Template = "_Home", Type = (int)SWCmsConstants.CateType.Home, CreatedBy = "Admin" - }); isSucceed = isSucceed && cate.SaveModel(false, context, transaction).IsSucceed; - BECategoryViewModel uscate = new BECategoryViewModel( new SiocCategory() + BECategoryViewModel uscate = new BECategoryViewModel(new SiocCategory() { Title = "Home", Specificulture = "en-us", @@ -400,15 +389,17 @@ public void InitSWCms() isSucceed = isSucceed && uscate.SaveModel(false, context, transaction).IsSucceed; } - if (isSucceed) { - GlobalLanguageService.Instance.RefreshCultures(context, transaction); - transaction.Commit(); IsInit = true; } + else + { + transaction.Rollback(); + IsInit = false; + } } } catch (Exception ex) // TODO: Add more specific exeption types instead of Exception only @@ -524,4 +515,4 @@ public int GetLocalInt(string key, string culture, int defaultValue) return result; } } -} +} \ No newline at end of file