Example #1
0
 public AdsController(ArticleService articleService, ArticleTypeService articleTypeService,
                      ResourceService resourceService, CustomerService customerService, IList <IBuilder <ArticleViewModel> > builders)
 {
     _articleService     = articleService;
     _articleTypeService = articleTypeService;
     _resourceService    = resourceService;
     _customerService    = customerService;
     _builders           = builders;
 }
Example #2
0
        /// <summary>
        /// 获取文章分类
        /// </summary>
        /// <param name="typeIds"></param>
        /// <returns></returns>
        private IList <LoT.Model.ArticleType> GetBottomArticleType(string typeIds = "")
        {
            IList <LoT.Model.ArticleType> articleList = new List <LoT.Model.ArticleType>();

            int[] ids = typeIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray();

            if (ids.Length == 0)
            {
                return(articleList);
            }

            int index = ids[ids.Length - 1];

            //分类一
            var articleTypeOne = ArticleTypeService.FindModel(index);

            //分类不存在就滚蛋
            if (articleTypeOne == null || articleTypeOne.Status == StatusEnum.Delete)
            {
                return(articleList);
            }
            articleList.Add(articleTypeOne);

            //没二级就滚蛋
            if (articleTypeOne.ParentType == null || articleTypeOne.ParentType.Status == StatusEnum.Delete)
            {
                return(articleList);
            }

            //分类二
            var articleTypeTwo = articleTypeOne.ParentType;

            articleList.Add(articleTypeTwo);

            //没三级就滚蛋
            if (articleTypeTwo.ParentType == null || articleTypeTwo.ParentType.Status == StatusEnum.Delete)
            {
                return(articleList);
            }

            //分类三
            articleList.Add(articleTypeTwo.ParentType);

            return(articleList);
        }
Example #3
0
        /// <summary>
        /// 根据ID获取子分类,当子分类为0显示顶级分类
        /// </summary>
        /// <param name="id">分类id,0表示显示顶级菜单</param>
        /// <returns></returns>
        public ActionResult NavForType(int id = 0)
        {
            if (id <= 0)
            {
                ViewBag.MenuTypes = ArticleTypeService.PageLoad(t => t.Status != StatusEnum.Delete && (t.Pid == 0 || t.Pid == null)).ToList();
            }
            else
            {
                //本分类
                ViewBag.articleTypeMe = ArticleTypeService.PageLoad(t => t.Status != StatusEnum.Delete && (t.Id == id)).FirstOrDefault();

                var articleTypes = ArticleTypeService.PageLoad(t => t.Status != StatusEnum.Delete && (t.Pid == id)).ToList();
                if (articleTypes != null && articleTypes.Count > 0)
                {
                    ViewBag.MenuTypes = articleTypes;
                }
            }

            return(View());
        }
Example #4
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     _articleTypeService = _articleTypeService ?? new ArticleTypeService();
     filterContext.Controller.ViewData[ViewDataKeys.ArticleCategory] = new SelectList(_articleTypeService.Get(), "ID", "Title");
 }
Example #5
0
 /// <summary>
 /// 获取所有稿件类型
 /// </summary>
 /// <returns></returns>
 public static DataTable GetArticleTypeList()
 {
     return(ArticleTypeService.GetAllArticleTypes());
 }