public ActionResult BoardCommentUpdate(int iBoardCommentID) { // Instantiate objects BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); BoardCommentMapper lBoardCommentMapper = new BoardCommentMapper(); // Find the BoardComment by boardCommentIDPK BoardCommentDBO lBoardCommentDBO = lBoardCommentBLL.FindBoardCommentByBoardCommentID(iBoardCommentID); BoardComment lBoardComment = new BoardComment(); if (lBoardCommentDBO != null) { // Map DB object to Model and pre-populate the comment lBoardComment = lBoardCommentMapper.MapBoardCommentDBOToBoardComment(lBoardCommentDBO); } else { // redirect to the post with error message TempData["msg"] = "<script> alert('Error occured while processing your request.') </script>"; return(RedirectToAction("BoardView", "Board", new { @id = iBoardCommentID })); } return(PartialView("BoardCommentUpdate", lBoardComment)); }
public ActionResult BoardView(int id) { // Instantiate BCViewModel to pass three models BoardAndCommentsViewModel lBCViewModel = new BoardAndCommentsViewModel(); // Instantiate Mapper Objects BoardCommentMapper lBCMapper = new BoardCommentMapper(); BoardMapper lBoardMapper = new BoardMapper(); // Instantiate BLL Objects BoardBLL lBoardBLL = new BoardBLL(); BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // Retreive data for post from database based on BoardIDPK BoardDBO lBoardDBO = lBoardBLL.FindBoardByBoardID(id); // if there is no post with the id, redirect to board list with error message if (lBoardDBO == null) { TempData["msg"] = "<script>alert('Error occured while processing your request.')</script>"; return(RedirectToAction("BoardList", "Board")); } // Retreive data for comments from database based on BoardIDPK List <BoardCommentDBO> lBoardCommentDBOList = lBoardCommentBLL.GetAllCommentsByBoardID(id); // Map DB objects to Model.BoardComment lBCViewModel.BoardCommentList = lBCMapper.MapBoardCommentDBOToBoardComment(lBoardCommentDBOList); lBCViewModel.Board = lBoardMapper.MapBoardDBOToBoard(lBoardDBO); // set values for board comment lBCViewModel.BoardComment = new BoardComment(); lBCViewModel.BoardComment.BoardIDFK = lBCViewModel.Board.BoardIDPK; lBCViewModel.BoardComment.UserIDFK = Convert.ToInt32(Session["AUTHUserIDPK"]); return(View(lBCViewModel)); }