public ActionResult BoardCommentCreate(BoardAndCommentsViewModel iBoardComment) { // check if all inputs are valid if (ModelState.IsValid) { // Increate Mapper object BoardCommentMapper lBoardCommentMapper = new BoardCommentMapper(); // Map Model.BoardComment to BoardCommentDBO BoardCommentDBO lBoardCommentDBO = lBoardCommentMapper.MapBoardCommentToBoardCommentDBO(iBoardComment); // Instantiate BoardCommentBLL object BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // Insert into Database and get BoardComment ID PK as return value int lResult = lBoardCommentBLL.CreateBoardComment(lBoardCommentDBO); // If successfully inserted, redirect to the post if (lResult > 0) { // message on success TempData["msg"] = "<script>alert('Successfully Written!');</script>"; return(RedirectToAction("BoardView", "Board", new { id = lBoardCommentDBO.BoardIDFK })); } else { // error message TempData["msg"] = "<script> alert('Error occured while processing your requset. Please try later.') </script>"; } } else { // error message TempData["msg"] = "<script> alert('Please all Required Fields.') </script>"; } // redirect to post with error message return(RedirectToAction("BoardView", "Board", new { id = iBoardComment.BoardComment.BoardIDFK })); }
public ActionResult BoardCommentUpdate(BoardComment iBoardComment) { // instantiate objects BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); BoardCommentMapper lBoardCommentMapper = new BoardCommentMapper(); // Map Model to DB objects BoardCommentDBO lBoardCommentDBO = lBoardCommentMapper.MapBoardCommentToBoardCommentDBO(iBoardComment); // Get bool result for updating comment bool lResult = lBoardCommentBLL.UpdateBoardCommentByBoardCommentID(lBoardCommentDBO); if (lResult) { TempData["msg"] = "<script> alert('Successfully Updated!') </script>"; // redirect to the board view return(RedirectToAction("BoardView", "Board", new { id = iBoardComment.BoardIDFK })); } else { return(Json(new { success = false })); } }