コード例 #1
0
        /// <summary>
        /// 设定首页推荐文章
        /// </summary>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult SetTopArticle(string ArticleId)
        {
            if (Session[ConstHelper.Session_USERID] == null || (UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Admin)
            {
                return(Redirect("/"));
            }
            if (string.IsNullOrEmpty(ArticleId))
            {
                return(Redirect("/"));
            }
            ViewBag.Title = "设定首页推荐文章";
            ArticleListManager.SetTopArticle(ArticleId);
            var config = SiteConfig.GetSiteConfigBySn("00000001");

            if (config != null)
            {
                config.TopArticleID = ArticleId;
                SiteConfig.UpdateSiteConfig(config);
            }
            return(Redirect("/"));
        }
コード例 #2
0
        /// <summary>
        /// 获得配置文件内容
        /// </summary>
        public static void GetConfig()
        {
            var config = SiteConfig.GetSiteConfigBySn("00000001");

            if (config == null)
            {
                MongoDbRepository.InsertRec(new SiteConfig());
            }
            else
            {
                if (config.CatalogItem != null && config.CatalogItem.Length != 0)
                {
                    Article.CatalogItem = config.CatalogItem;
                }
                else
                {
                    config.CatalogItem = Article.CatalogItem;
                    SiteConfig.UpdateSiteConfig(config);
                }
                ArticleListManager.SetTopArticle(config.TopArticleID);
            }
        }