예제 #1
0
        public ActionResult CheckArticleInfo(string title, string board_id, string theme_id, string article_txt)
        {
            Method.ValueIsEmpty(title);
            Method.ValueIsEmpty(board_id);
            Method.ValueIsEmpty(theme_id);
            Method.ValueIsEmpty(article_txt);
            if (Method.ValueIsEmpty_Val)
            {
                return(View("LaunchArticle", (HomeViewModel)Session["ViewModel"]));
            }
            //int getBoardId = Service_Board_P.GetBoardIdOfTheme_Md(int.Parse(theme_id.Trim()));
            int getBoardId = Service_Board_P.GetBoardIdOfTheme_Md(int.Parse(theme_id.Trim()));

            if (getBoardId != int.Parse(board_id.Trim()))
            {
                TempData[InternalVal._RESULTMSG] = "該討論版無此分類!請重新發佈文章!";
                return(RedirectToAction("ResultMessage", "Home"));
            }
            article_Tb articleItem = new article_Tb()
            {
                title      = title.Trim(),
                arti_txt   = article_txt.Trim(),
                board_id   = int.Parse(board_id.Trim()),
                arti_theme = int.Parse(theme_id.Trim()),
                user_id    = Service_User_P.GetUserInfo_Md(Session[InternalVal._SESSIONACCOUNT].ToString()).user_id
            };

            return(RedirectToAction("AddArticle", articleItem));
        }
예제 #2
0
        public PartialViewResult _NewArticle()
        {
            HomeViewModel     viewModel   = new HomeViewModel();
            List <article_Tb> articleList = new List <article_Tb>();
            List <board_Tb>   boardList   = new List <board_Tb>();
            List <user_Tb>    userList    = new List <user_Tb>();

            //標題字數
            articleList           = Service_Article_P.ListArticle_Md(null, null).OrderByDescending(m => m.arti_date).Take(5).ToList();
            viewModel.articleList = articleList;
            for (int i = 0; i < articleList.Count(); i++)
            {
                articleList[i].title    = Method.StrSubstring(articleList[i].title, 0, 50);
                articleList[i].arti_txt = Method.StrSubstring(articleList[i].arti_txt, 0, 100);
                boardList.Add(new board_Tb()
                {
                    id             = (int)articleList[i].arti_theme,
                    theme_board_id = articleList[i].board_id,
                    board_name     = Service_Board_P.GetBoardName_Md(articleList[i].board_id)
                });
                userList.Add(new user_Tb()
                {
                    user_id  = articleList[i].user_id,
                    username = Service_User_P.GetUserInfo_Md(articleList[i].user_id).username
                });
            }
            viewModel.articleList  = articleList;
            viewModel.boardList    = boardList;
            viewModel.userInfoList = userList;
            return(PartialView(viewModel));
        }
예제 #3
0
        /// <summary>
        /// 觀看文章
        /// </summary>
        /// <param name="article"></param>
        /// <param name="board"></param>
        /// <param name="theme"></param>
        /// <returns></returns>
        public ActionResult ReviewArticle(int?article, int?board, int?theme)
        {
            HomeViewModel viewModel = new HomeViewModel();

            //文章ID為空直接跳轉至該討論版
            Method.ValueIsEmpty(article);
            if (Method.ValueIsEmpty_Val)
            {
                return(RedirectToAction("BoardArticle", new { board = board }));
            }
            //討論版ID為空直接跳轉至首頁
            Method.ValueIsEmpty(board);
            if (Method.ValueIsEmpty_Val)
            {
                return(RedirectToAction("Index", "Home"));
            }
            article_Tb articleItem = new article_Tb();

            articleItem = Service_Article_P.GetArticle_Md((int)article);
            //檢查該筆文章是否符合
            if (articleItem.arti_id != article || articleItem.board_id != board || articleItem.arti_theme != theme)
            {
                TempData[InternalVal._RESULTMSG] = "無該筆文章!";
                return(RedirectToAction("ResultMessage", "Home"));
            }
            //獲取當前的URL參數
            TempData["ArticleUrl"]         = Request.Url.Query;
            TempData["ArticleQueryString"] = Request.QueryString;
            //文章內容資訊
            viewModel.articleItem = articleItem;
            viewModel.replyCount  = Service_Article_P.GetArticleReplyCount_Md((int)article);
            viewModel.boardItem   = new board_Tb()
            {
                id         = (int)board,
                board_name = Service_Board_P.GetBoardName_Md((int)board)
            };
            viewModel.userItem = Service_User_P.GetUserInfo_Md(articleItem.user_id);
            //文章回覆
            List <article_reply_Tb> replyArticleItems = Service_Article_P.ListArticleReply_Md((int)article).ToList();

            viewModel.replyAritlceList = replyArticleItems;
            List <user_Tb> userItems = new List <user_Tb>();

            for (int i = 0; i < replyArticleItems.Count(); i++)
            {
                userItems.Add(Service_User_P.GetUserInfo_Md(replyArticleItems[i].user_id));
            }
            viewModel.userInfoList = userItems;
            return(View(viewModel));
        }
예제 #4
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));
        }
예제 #5
0
        public ActionResult _Header()
        {
            IList <board_Tb> objItem         = Service_Board_P.ListBoard_Md().OrderBy(m => m.id).ToList();
            HomeViewModel    HomeViewModel_P = new HomeViewModel();

            HomeViewModel_P.boardList = objItem;
            string account = Convert.ToString(Session[InternalVal._SESSIONACCOUNT] ?? "").Trim();

            ViewData["onLogin"] = false;    //預設未登入
            //是否已登入
            if (!string.IsNullOrEmpty(account))
            {
                ViewData["onLogin"]  = true;
                ViewData["username"] = Convert.ToString(Session[InternalVal._SESSIONNAME].ToString());
            }
            return(PartialView(HomeViewModel_P));
        }
예제 #6
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));
        }
예제 #7
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));
        }
예제 #8
0
        public ActionResult ReplyArticle(int?article, int?board, int?theme, int?reply)
        {
            //判斷是否有文章編號
            Method.ValueIsEmpty(article);
            if (Method.ValueIsEmpty_Val)
            {
                return(RedirectToAction("Index", "Home"));
            }
            HomeViewModel    viewModel   = new HomeViewModel();
            article_Tb       articleItem = new article_Tb();
            article_reply_Tb replyItem   = new article_reply_Tb();
            int num = (int)article;

            articleItem       = Service_Article_P.GetArticle_Md(num);
            articleItem.title = Method.StrSubstring(articleItem.title, 0, 50);
            board_Tb boardItem = new board_Tb();

            boardItem            = Service_Board_P.BoardItem_Md(null, theme);
            viewModel.replyCount = Service_Article_P.GetArticleReplyCount_Md((int)article);
            //回覆樓主
            TempData["replyAuthor"] = true;
            if (boardItem.theme_board_id != board && boardItem.id != theme)
            {
                TempData[InternalVal._RESULTMSG] = "發生錯誤!無法回覆文章!";
                return(RedirectToAction("ResultMessage", "Home"));
            }
            if (reply != null)
            {
                replyItem               = Service_Article_P.GetArticleReply_Md(reply);
                articleItem.arti_txt    = "\"引用:" + Method.StrSubstring(replyItem.reply_txt, 0, 30) + "\"";
                TempData["replyAuthor"] = false;
            }
            boardItem.theme_board_id = articleItem.board_id;
            boardItem.id             = (int)theme;
            boardItem.board_name     = Service_Board_P.GetBoardName_Md((int)board);
            boardItem.theme_name     = boardItem.theme_name;
            viewModel.articleItem    = articleItem;
            viewModel.boardItem      = boardItem;
            return(View(viewModel));
        }
예제 #9
0
        public PartialViewResult _LeftHotArticle()
        {
            HomeViewModel           viewModel        = new HomeViewModel();
            List <article_Tb>       articleList      = new List <article_Tb>();
            List <board_Tb>         boardList        = new List <board_Tb>();
            List <user_Tb>          userList         = new List <user_Tb>();
            List <article_reply_Tb> articleReplyList = new List <article_reply_Tb>();

            articleList = Service_Article_P.ListArticle_Md(null, null).OrderByDescending(m => m.view_num).ThenByDescending(m => m.arti_id).Take(5).ToList();

            //文章最新回覆的用戶ID
            article_reply_Tb articleReplyItem = new article_reply_Tb();
            user_Tb          userItem         = new user_Tb();

            for (int i = 0; i < articleList.Count(); i++)
            {
                //標題字數
                articleList[i].title = Method.StrSubstring(articleList[i].title, 0, 30);
                //討論版名稱
                boardList.Add(new board_Tb()
                {
                    id             = (int)articleList[i].arti_theme,
                    board_name     = Service_Board_P.GetBoardName_Md(articleList[i].board_id),
                    theme_board_id = articleList[i].board_id
                });
                articleReplyItem = Service_Article_P.ListArticleReply_Md(articleList[i].arti_id).OrderByDescending(m => m.reply_id).FirstOrDefault();
                if (articleReplyItem != null)
                {
                    userItem = Service_User_P.GetUserInfo_Md(articleReplyItem.user_id);
                    userList.Add(userItem);
                    articleReplyList.Add(articleReplyItem);
                }
            }
            viewModel.articleList      = articleList;
            viewModel.boardList        = boardList;
            viewModel.userInfoList     = userList;
            viewModel.replyAritlceList = articleReplyList;
            return(PartialView(viewModel));
        }
예제 #10
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));
        }