Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Description: This method maps list of database objects to list of Model
        /// </summary>
        /// <param name="iBoardCommentDBOList">List of BoardComment database objects to be mapped</param>
        /// <returns>List of BoardComment Model</returns>
        public List <BoardComment> MapBoardCommentDBOToBoardComment(List <BoardCommentDBO> iBoardCommentDBOList)
        {
            // list to be returned
            List <BoardComment> lBoardCommentList = new List <BoardComment>();

            // loop through the input list and map each item to Model.BoardComment
            foreach (BoardCommentDBO lEachComment in iBoardCommentDBOList)
            {
                // Object to be added to the list
                BoardComment lBoardComment = new BoardComment();

                // set values
                lBoardComment.BoardCommentIDPK = lEachComment.BoardCommentIDPK;
                lBoardComment.UserIDFK         = lEachComment.UserIDFK;
                lBoardComment.UserName         = lEachComment.UserName;
                lBoardComment.UserRoleName     = lEachComment.UserRoleName;
                lBoardComment.BoardIDFK        = lEachComment.BoardIDFK;
                lBoardComment.Content          = lEachComment.Content;
                lBoardComment.DateCreated      = lEachComment.DateCreated;
                lBoardComment.DateModified     = lEachComment.DateModified;

                lBoardCommentList.Add(lBoardComment);
            }

            return(lBoardCommentList);
        }
Ejemplo n.º 3
0
        public int SaveComment(BoardComment commntInfo)
        {
            if (string.IsNullOrEmpty(commntInfo.CommetId.ToString()) || commntInfo.CommetId == 0)
            {
                commntInfo.UpdateDt = DateTime.Now;
                commntInfo.CreateDt = DateTime.Now;
                commntInfo.CreateId = System.Web.HttpContext.Current.User.Identity.GetUserId();
                commntInfo.UpdateId = System.Web.HttpContext.Current.User.Identity.GetUserId();

                context.BoardComments.Add(commntInfo);
                context.SaveChanges();
            }
            else
            {
                var updateRow = (from bcomm in context.BoardComments
                                 where bcomm.CommetId == commntInfo.CommetId
                                 select bcomm).Single();

                updateRow.CommentContent = commntInfo.CommentContent;
                updateRow.UpdateDt       = DateTime.Now;
                updateRow.UpdateId       = System.Web.HttpContext.Current.User.Identity.GetUserId();
            }

            return(commntInfo.CommetId);;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Description: This method maps Model object to database object
        /// </summary>
        /// <param name="iBoardComment">Object to be mapped</param>
        /// <returns>BoardCommentDBO object</returns>
        public BoardCommentDBO MapBoardCommentToBoardCommentDBO(BoardComment iBoardComment)
        {
            // Instantiate BoardCommentDBO object
            BoardCommentDBO lBoardCommentDBO = new BoardCommentDBO();

            // set values
            lBoardCommentDBO.BoardCommentIDPK = iBoardComment.BoardCommentIDPK;
            lBoardCommentDBO.Content          = iBoardComment.Content;

            return(lBoardCommentDBO);
        }
Ejemplo n.º 5
0
        public ActionResult SaveComment(BoardComment commntInfo)
        {
            if (ModelState.IsValid)
            {
                int commentId = dbPost.SaveComment(commntInfo);

                return(Json(dbPost.ViewComment(commentId), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = false, SaveError = "Not Saved" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Description: This method maps database object to Model object
        /// </summary>
        /// <param name="iBoardCommentDBO">Object to be mapped</param>
        /// <returns>BoardComment object</returns>
        public BoardComment MapBoardCommentDBOToBoardComment(BoardCommentDBO iBoardCommentDBO)
        {
            // Instantiate BoardComment object
            BoardComment lBoardComment = new BoardComment();

            // set values
            lBoardComment.BoardCommentIDPK = iBoardCommentDBO.BoardCommentIDPK;
            lBoardComment.UserIDFK         = iBoardCommentDBO.UserIDFK;
            lBoardComment.UserName         = iBoardCommentDBO.UserName;
            lBoardComment.UserRoleName     = iBoardCommentDBO.UserRoleName;
            lBoardComment.DateCreated      = iBoardCommentDBO.DateCreated;
            lBoardComment.Content          = iBoardCommentDBO.Content;
            lBoardComment.DateModified     = iBoardCommentDBO.DateModified;
            lBoardComment.BoardIDFK        = iBoardCommentDBO.BoardIDFK;

            return(lBoardComment);
        }
Ejemplo n.º 7
0
        public BoardComment ViewComment(int?commentId)
        {
            var results = (from brd in context.BoardComments
                           join urs in context.UserProfiles on brd.CreateId equals urs.UserId into bru
                           from uid in bru.DefaultIfEmpty()
                           join att in context.AttachFiles on uid.UserPic equals att.FileId into upic
                           from userpic in upic.DefaultIfEmpty()
                           where brd.CommetId == commentId && userpic.FileType == "USER_PROFILE"
                           select new
            {
                brd.PostId,
                brd.CommetId,
                brd.CommentContent,
                brd.CommentLevel,
                brd.ParentId,
                brd.CreateDt,
                brd.CreateId,
                brd.UpdateDt,
                brd.UpdateId,
                FullName = uid.FirstName + " " + uid.LastName,
                userpic = userpic.SaveAsFileName
            }).FirstOrDefault();


            var viweModel = new BoardComment
            {
                CommetId       = results.CommetId,
                PostId         = results.PostId,
                CommentLevel   = results.CommentLevel,
                ParentId       = results.ParentId,
                CommentContent = results.CommentContent,
                CreateDt       = results.CreateDt,
                CreateId       = results.CreateId,
                UpdateDt       = results.UpdateDt,
                UpdateId       = results.UpdateId,
                FullName       = results.FullName,
                UserPic        = results.userpic
            };

            return(viweModel);
        }
Ejemplo n.º 8
0
        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 }));
            }
        }
Ejemplo n.º 9
0
        public ActionResult BoardComment_action(BoardComment doc, string BD_idx, string cate, string mode_type, int?c_idx)
        {
            int idx = 0;

            string msg = "";

            #region 기본 사용자 정보
            string user_id        = User.Identity.Name;
            int    department_idx = Convert.ToInt32(UserData.user_get(user_id, "department_idx"));
            int    company_idx    = Convert.ToInt32(UserData.user_get(user_id, "company_idx"));
            int    auth           = Convert.ToInt32(UserData.user_get(user_id, "auth"));
            #endregion

            if (c_idx == null)
            {
                #region 저장

                doc.write_date = DateTime.Now;
                doc.writer     = User.Identity.Name;
                doc.edit_date  = DateTime.Now;
                doc.use_yn     = "Y";
                db.BoardComment.Add(doc);
                db.SaveChanges(); // 실제로 저장


                msg = admin_basic.Util.msg.msg_insert;

                #endregion
            }
            else
            {
                if (mode_type == "D")
                {
                    #region 삭제

                    BoardComment doc_del = db.BoardComment.Single(x => x.idx == c_idx);
                    db.BoardComment.Remove(doc_del);
                    db.SaveChanges();

                    msg = admin_basic.Util.msg.msg_del;

                    #endregion
                }

                else if (mode_type == "E")
                {
                    #region 임시 삭제 / 상태 변환 업데이트

                    BoardComment _update =
                        (from a in db.BoardComment where a.idx == c_idx select a).Single();
                    _update.edit_date = DateTime.Now;
                    _update.use_yn    = "D";
                    _update.writer    = User.Identity.Name;

                    db.SaveChanges(); // 실제로 저장


                    msg = admin_basic.Util.msg.msg_disable;

                    #endregion
                }
                else
                {
                    #region 수정


                    BoardComment _update =
                        (from a in db.BoardComment where a.idx == idx select a).Single();

                    _update.edit_date = DateTime.Now;
                    _update.memo      = doc.memo;


                    db.SaveChanges(); // 실제로 저장



                    msg = admin_basic.Util.msg.msg_edit;

                    #endregion
                }
            }
            string url = "/board/boardview?idx=" + BD_idx + "&cate=" + cate;

            return(Redirect(url));
        }