Example #1
0
        public IActionResult ShowDetail(string path, string filename)
        {
            string fullPath = $"/{path}";
            //先判断文章栏目
            ArticleCategory articleCategory = ArticleCategory.FindByFilePath(fullPath);

            if (articleCategory != null)
            {
                Article article = null;
                //判断文件名
                if (Utils.IsInt(filename))
                {
                    article = Article.FindById(int.Parse(filename));
                }
                if (article == null)
                {
                    filename = filename + ".html";
                    article  = Article.FindByFileName(filename, articleCategory.Id);
                }
                if (article != null)
                {
                    ArticleController ac = new ArticleController();
                    return(ac.Detail(article.Id));
                }
            }
            //再判断商品
            Category category = Category.FindByFilePath(fullPath);

            if (category != null)
            {
                Product product = null;
                //判断文件名
                if (Utils.IsInt(filename))
                {
                    product = Product.FindById(int.Parse(filename));
                }
                if (product == null)
                {
                    filename = filename + ".html";
                    product  = Product.FindByFileName(filename, articleCategory.Id);
                }
                if (product != null)
                {
                    ProductController pc = new ProductController();
                    return(pc.Detail(product.Id));
                }
            }

            return(EchoTip("系统找不到本详情!" + "/" + path + "/" + filename));
        }
Example #2
0
        //[Route("{path:regex(^(?!swagger\\b)[[a-zA-Z0-9-]]+$)}/")]
        public IActionResult ShowCategory(string path, int page = 1)
        {
            //先判断文章栏目
            ArticleCategory articleCategory = ArticleCategory.FindByFilePath("/" + path);

            if (articleCategory != null)
            {
                //return Content(articleCategory.Id.ToString());
                ArticleController ac = new ArticleController();
                return(ac.Index(articleCategory.Id, page));
            }
            //再判断商品
            Category category = Category.FindByFilePath("/" + path);

            if (category != null)
            {
                ProductController pc = new ProductController();
                return(pc.Index(category.Id, page));
            }
            return(EchoTip("系统找不到本栏目!" + "/" + path));
        }