Exemple #1
0
        /// <summary>
        /// AJAX動態生成討論版分類
        /// </summary>
        /// <param name="board"></param>
        /// <returns></returns>
        public JsonResult LaunchArticleTheme(int board)
        {
            List <board_Tb> boardItems = new List <board_Tb>();

            boardItems = Service_Board_P.ListTheme_Md(board);
            List <object> Date = new List <object>();

            foreach (var item in boardItems)
            {
                Date.Add(new {
                    id         = item.id,
                    theme_name = item.theme_name
                });
            }
            return(Json(Date, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        /// <summary>
        /// 討論版文章列表
        /// </summary>
        /// <param name="board"></param>
        /// <param name="theme"></param>
        /// <returns></returns>
        public ActionResult BoardArticle(int?board, int?theme)
        {
            HomeViewModel   viewModel  = new HomeViewModel();
            List <board_Tb> themeItems = new List <board_Tb>();

            viewModel.boardItem = new board_Tb();
            //如果board參數無值以及負數導向首頁
            Method.ValueIsEmpty(board);
            if (Method.ValueIsEmpty_Val || board < 0)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.boardId = board;
            //如果theme參數無值以及負數導向該版全部主題
            Method.ValueIsEmpty(theme);
            if (Method.ValueIsEmpty_Val || theme < 0)
            {
                theme = 0;
            }
            //目前討論版資訊
            viewModel.boardItem.id         = (int)board;
            viewModel.boardItem.board_name = Service_Board_P.GetBoardName_Md((int)board);
            //獲取討論版分類項目
            themeItems          = Service_Board_P.ListTheme_Md((int)board);
            viewModel.boardList = themeItems;
            //獲取全部主題或該項目文章列表
            List <article_Tb> articleItems = new List <article_Tb>();

            articleItems          = (theme != 0) ? Service_Article_P.ListArticle_Md(board, theme).OrderByDescending(m => m.arti_date).ToList() : Service_Article_P.ListArticle_Md(board, null).OrderByDescending(m => m.arti_date).ToList();
            viewModel.articleList = articleItems;
            List <user_Tb> userItems = new List <user_Tb>();

            viewModel.replyCountList = new List <int>();
            //各文章回覆數量
            for (int i = 0; i < articleItems.Count(); i++)
            {
                articleItems[i].title    = Method.StrSubstring(articleItems[i].title, 0, 50);
                articleItems[i].arti_txt = Method.StrSubstring(articleItems[i].arti_txt, 0, 100);
                int sum = Service_Article_P.GetArticleReplyCount_Md(articleItems[i].arti_id);
                viewModel.replyCountList.Add(sum);
                userItems.Add(Service_User_P.GetUserInfo_Md(articleItems[i].user_id));
            }
            viewModel.userInfoList = userItems;
            return(View(viewModel));
        }
Exemple #3
0
        public ActionResult EditArticle(int article, int board, int theme)
        {
            HomeViewModel   viewModel   = new HomeViewModel();
            board_Tb        boardItem   = new board_Tb();
            article_Tb      articleItem = new article_Tb();
            List <board_Tb> themeItems  = new List <board_Tb>();

            articleItem              = Service_Article_P.GetArticle_Md(article);
            boardItem                = Service_Board_P.BoardItem_Md(null, theme);
            boardItem.id             = theme;
            boardItem.theme_board_id = board;
            boardItem.board_name     = Service_Board_P.GetBoardName_Md(board);
            themeItems               = Service_Board_P.ListTheme_Md(board);
            viewModel.articleItem    = articleItem;
            viewModel.boardItem      = boardItem;
            viewModel.themeList      = themeItems;
            return(View(viewModel));
        }
Exemple #4
0
        public ActionResult LaunchArticle(int?board, int?theme)
        {
            HomeViewModel viewModel = new HomeViewModel();

            viewModel.boardList = new List <board_Tb>();
            board_Tb        boardItem  = new board_Tb();
            List <board_Tb> themeItems = new List <board_Tb>();

            //討論版ID如為空
            Method.ValueIsEmpty(board);
            if (Method.ValueIsEmpty_Val)
            {
                //獲取全部討論版,在選取後由AJAX取得分類(LaunchArticleTheme)
                viewModel.boardList = Service_Board_P.ListBoard_Md().OrderBy(m => m.id).ToList();
            }
            else
            {
                //當前討論版資訊
                Method.ValueIsEmpty(theme);
                if (!Method.ValueIsEmpty_Val)
                {
                    boardItem.id = (int)theme;
                }
                boardItem.theme_board_id = (int)board;
                boardItem.board_name     = Service_Board_P.GetBoardName_Md((int)board);
                //獲取討論版分類
                themeItems = Service_Board_P.ListTheme_Md((int)board);
                //無討論版分類

                //themeItems = Service_Board_P.ListTheme_Md((int)board);
            }
            viewModel.themeList   = themeItems;
            viewModel.boardItem   = boardItem;
            viewModel.articleItem = new article_Tb();
            Session["ViewModel"]  = viewModel;

            return(View(viewModel));
        }