コード例 #1
0
        public MainPageSettings GetMainPage()
        {
            var item = _mainRepo.GetAll().FirstOrDefault();

            if (item == null)
            {
                item = CreateMainMageSettings(new MainPageSettings());
            }

            return(item);
        }
コード例 #2
0
        public static void ReloadSettings()
        {
            SiteSettings = _siteRepo.GetAll().FirstOrDefault();
            MailSettings = _mailRepo.GetAll().FirstOrDefault();
            SmsSettings  = _smsRepo.GetAll().FirstOrDefault();
            LastComments = _commentRepo.GetByCustomQuery("select * from Comments where IsPublish = 1 order by ID desc", null).ToList();
            ContentViews = _contentRepo.GetPublishedViewList();
            Writers      = _userRepo.GetByCustomQuery("select * from Users where (select COUNT(*) from UserRoleRels ur where ur.RoleID = 2) > 0 and IsActive = 1 and IsApproved = 1", null).ToList();

            Categories = _catRepo.GetByCustomQuery("select * from Categories where IsActive = 1", null).ToList();

            StaticPages = _staticRepo.GetAll();

            MainPageSetting = _mainRepo.GetAll().FirstOrDefault();

            MainPageSliders = _sliderRepo.GetAll();

            if (LastComments == null)
            {
                LastComments = new List <Comments>();
            }

            if (SiteSettings == null)
            {
                SiteSettings = new SiteSettings();
            }
            if (MailSettings == null)
            {
                MailSettings = new MailSettings();
            }
            if (SmsSettings == null)
            {
                SmsSettings = new SmsSettings();
            }

            if (ContentViews == null)
            {
                ContentViews = new List <ContentViewListModel>();
            }

            if (Writers == null)
            {
                Writers = new List <Users>();
            }

            if (Categories == null)
            {
                Categories = new List <Categories>();
            }

            if (StaticPages == null)
            {
                StaticPages = new List <StaticPages>();
            }

            if (MainPageSetting == null)
            {
                MainPageSetting = new MainPageSettings();
            }

            if (MainPageSliders == null)
            {
                MainPageSliders = new List <MainSliderSettings>();
            }
        }