Example #1
0
        public bool UpdateBoard_Md(board_Tb BoardInfo)
        {
            board_Tb objItem = db.board_Tb.FirstOrDefault(m => m.id == BoardInfo.id && m.theme_board_id == 0);

            objItem.board_name = BoardInfo.board_name.ToString();
            return(db.SaveChanges() > 0);
        }
Example #2
0
        /// <summary>
        /// 獲取討論版區塊分類的討論版編號
        /// </summary>
        /// <param name="themeId">分類編號</param>
        /// <returns></returns>
        /// theme_board_id 就是討論版的編號
        public int GetBoardIdOfTheme_Md(int themeId)
        {
            int      id     = 0;
            string   strSql = "select theme_board_id from board_tb where id = @id";
            board_Tb result = conn.Query <board_Tb>(strSql, new { id = themeId }).FirstOrDefault();

            id = result.id;
            return(id);
        }
Example #3
0
        public bool InsertBoard_Md(board_Tb addBoardInfo)
        {
            string strSql   = "insert into board_tb (board_name) values(@board_name)";
            var    newboard = new board_Tb
            {
                board_name = addBoardInfo.board_name
            };

            return(conn.Execute(strSql, newboard) > 0);
        }
Example #4
0
        public bool InsertBoard_Md(board_Tb addBoardInfo)
        {
            string strSql = "insert into board_tb (board_name) values(@board_name)";

            SqlParameter[] sqlParameters = new SqlParameter[] {
                new SqlParameter("@board_name", SqlDbType.NVarChar)
            };
            sqlParameters[0].Value = addBoardInfo.board_name;
            return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, sqlParameters) > 0);
        }
Example #5
0
        public bool InsertTheme_Md(board_Tb addBoardInfo)
        {
            string strSql = "insert into board_tb (theme_board_id, theme_name) values(@theme_board_id, @theme_name)";

            board_Tb boardItem = new board_Tb
            {
                theme_board_id = addBoardInfo.theme_board_id,
                theme_name     = addBoardInfo.theme_name
            };

            return(conn.Execute(strSql, boardItem) > 0);
        }
Example #6
0
        public bool InsertTheme_Md(board_Tb addBoardInfo)
        {
            string strSql = "insert into board_tb (theme_board_id, theme_name) values(@theme_board_id, @theme_name)";

            SqlParameter[] sqlParameters = new SqlParameter[] {
                //插入為討論版id
                new SqlParameter("@theme_board_id", SqlDbType.NVarChar),
                new SqlParameter("@theme_name", SqlDbType.NVarChar)
            };
            sqlParameters[0].Value = addBoardInfo.theme_board_id;
            sqlParameters[1].Value = addBoardInfo.theme_name;
            return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql, sqlParameters) > 0);
        }
Example #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));
        }
Example #8
0
        /// <summary>
        /// 獲得討論版資訊
        /// </summary>
        /// <returns></returns>
        public board_Tb BoardItem_Md(int?boardId, int?themeId)
        {
            board_Tb objItem = new board_Tb();

            if (boardId != null && themeId != null)
            {
                objItem = db.board_Tb.FirstOrDefault(m => m.id == themeId && m.theme_board_id == boardId);
            }
            else if (boardId != null)
            {
                objItem = db.board_Tb.FirstOrDefault(m => m.id == boardId);
            }
            else if (themeId != null)
            {
                objItem = db.board_Tb.FirstOrDefault(m => m.id == themeId);
            }
            return(objItem);
        }
Example #9
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));
        }
Example #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));
        }
Example #11
0
 public bool UpdateTheme_Md(board_Tb BoardInfo)
 {
     return(Repository_Board_P.UpdateBoard_Md(BoardInfo));
 }
Example #12
0
 public bool InsertTheme_Md(board_Tb addBoardInfo)
 {
     return(Repository_Board_P.InsertTheme_Md(addBoardInfo));
 }