public ActionResult UserProfile(int id, Common notice) { // Instantiate objects UserBLL lUserBLL = new UserBLL(); UserMapper lUserMapper = new UserMapper(); BoardBLL lBoardBLL = new BoardBLL(); RestaurantBLL lRestaurantBLL = new RestaurantBLL(); BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // Instantiate object to hold all info about user UserRestaurantBoardUtil lUserAllData = new UserRestaurantBoardUtil(); // Get info about user with id lUserAllData.UserData = lUserBLL.FindUserByID(id); // Get info about board with user id lUserAllData.BoardList = lBoardBLL.GetAllBoardsByUserID(id); lUserAllData.BoardCommentList = lBoardCommentBLL.GetAllCommentsByUserID(id); // Get info about order with user id lUserAllData.OrderList = lRestaurantBLL.GetAllOrdersByUserID(id); // number of rows per page lUserAllData.PageSize = 10; return(View(lUserAllData)); }
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 BoardCommentRemove(int id, int boardID) { // Instantiate BLL object BoardCommentBLL lBoardCommentBLL = new BoardCommentBLL(); // get bool as return value if comment is successfully removed bool lResult = lBoardCommentBLL.RemoveBoardCommentByBoardCommentID(id); if (lResult) { // message on success TempData["msg"] = "<script>alert('Successfully Removed!');</script>"; } else { // message on failure TempData["msg"] = "<script>alert('Your request failed. Please try again');</script>"; } // redirect to the board view return(RedirectToAction("BoardView", "Board", new { id = boardID })); }
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 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)); }
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 })); } }