Example #1
0
        public ActionResult ChannelList(string alias)
        {
            //根据别名获得技术分类详细信息
            var techModel = TechService.GetTechInfoByAlias(alias);

            if (techModel.Id == 0 || techModel.IsDeleted)
            {
                return(Content("Argument error."));
            }
            //获得栏目ID
            int catId   = CECRequest.GetQueryInt("catid", 0);
            var catInfo = ColumnService.GetById(catId);

            int pageIndex = CECRequest.GetQueryInt("page", 1);

            var articleList = ArticleService.List(new Models.ArticleSearchSetting()
            {
                PageIndex = pageIndex,
                ColumnIds = new int[] { catId },
                TechIds   = new int[] { techModel.Id },
                IsDeleted = false
            });

            ViewBag.TechInfo    = techModel;
            ViewBag.ColumnInfo  = catInfo;
            ViewBag.ArticleList = articleList;
            return(View());
        }
Example #2
0
        public ActionResult Edit()
        {
            int id         = CECRequest.GetQueryInt("id", 0);
            var columnInfo = ColumnService.GetById(id);

            if (columnInfo.Id <= 0)
            {
                return(RedirectToAction("List"));
            }
            return(View(columnInfo));
        }
Example #3
0
        public ActionResult List()
        {
            int catId     = CECRequest.GetQueryInt("catid", 0);
            int pageIndex = CECRequest.GetQueryInt("page", 1);

            ViewBag.CategoryInfo = ColumnService.GetById(catId);
            var articleList = ArticleService.List(new ArticleSearchSetting()
            {
                ColumnIds = new int[] { catId },
                PageIndex = pageIndex,
                IsDeleted = false
            });

            ViewBag.ArticleList = articleList;
            return(View());
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult Show()
        {
            Regex  r        = new Regex(@"/(\d+).html", RegexOptions.IgnoreCase);
            Match  m        = r.Match(Request.Url.LocalPath);
            string timespan = string.Empty;

            if (m.Success)
            {
                timespan = m.Groups[1].Value;
            }
            var model = ArticleService.GetByTimespan(timespan);

            ViewBag.CategoryInfo = ColumnService.GetById(model.CategoryId);

            //获得10条相关文章
            ViewBag.RelatedArticleList = ArticleService.GetRelatedArticleList(10, model.Id, model.Tags);

            //更新文章浏览量
            ArticleService.UpdateViewCount(model.Id);

            return(View(model));
        }
Example #5
0
        public ActionResult List()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                //POST
                var action = CECRequest.GetFormString("action").ToLower();
                if (action == "addparent")
                {
                    //添加父节点
                    string name = CECRequest.GetFormString("txtParentName");
                    if (string.IsNullOrEmpty(name))
                    {
                        ModelState.AddModelError("PNAMEEMPTY", "根栏目名称不能为空");
                    }
                    if (ModelState.IsValid)
                    {
                        //Insert
                        ColumnService.Create(new ColumnInfo()
                        {
                            Name      = name,
                            Alias     = string.Empty,
                            ParentId  = 0,
                            RootId    = 0,
                            IsDeleted = false,
                            ParentIds = "0",
                            Sort      = 999999
                        });
                        ViewBag.Msg = "根栏目添加成功";
                    }
                }
                if (action == "addchild")
                {
                    //添加子节点
                    string name = CECRequest.GetFormString("txtChildName");
                    if (string.IsNullOrEmpty(name))
                    {
                        ModelState.AddModelError("CNAMEEMPTY", "子栏目名称不能为空");
                    }
                    if (ModelState.IsValid)
                    {
                        //保存
                        int parentId         = Utils.StrToInt(CECRequest.GetFormString("select_column"), 0);
                        var parentColumnInfo = ColumnService.GetById(parentId);
                        if (parentColumnInfo.Id > 0)
                        {
                            //RootId
                            int rootId = parentColumnInfo.RootId;
                            if (parentColumnInfo.ParentId == 0)
                            {
                                //说明是根分类
                                rootId = parentColumnInfo.Id;
                            }
                            //ParentIds
                            string parentIds = string.Format("{0},{1}", parentColumnInfo.ParentIds, parentColumnInfo.Id);

                            ColumnService.Create(new ColumnInfo()
                            {
                                Alias     = string.Empty,
                                IsDeleted = false,
                                Name      = name,
                                ParentId  = parentId,
                                ParentIds = parentIds,
                                RootId    = rootId,
                                Sort      = 999999
                            });
                            ViewBag.Msg = "子栏目添加成功";
                        }
                    }
                }
            }

            //创建下拉列表
            var allColumn    = ColumnService.List().ToList();
            var dropdownList = new List <ColumnInfo>();

            ColumnService.BuildListForTree(dropdownList, allColumn, 0);
            ViewBag.DropDownList = dropdownList;

            ViewBag.ColumnListHtml = _BuildColumnList(allColumn, 0);


            return(View());
        }