Ejemplo n.º 1
0
        // GET api/<controller>/5
        public Board Get(int boardNum)
        {
            Board board;

            using (var db = new BoardSystemContext())
            {
                board = db.Boards.FirstOrDefault(u => u.BoardNum.Equals(boardNum));
                db.Entry(board).Entity.BoardViews = board.BoardViews + 1;
                db.SaveChanges();
            }
            return(board);
        }
Ejemplo n.º 2
0
        public IActionResult Detail(int boardNum)
        {
            if (HttpContext.Session.GetString("USER_LOGIN_KEY") == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            using (var db = new BoardSystemContext())
            {
                Board board;
                IEnumerable <Comment> commentList;
                try
                {
                    board = db.Boards.FirstOrDefault(n => n.BoardNum.Equals(boardNum));
                    db.Entry(board).Entity.BoardViews = board.BoardViews + 1;
                    db.SaveChanges();
                    commentList         = db.Comments.ToList().Where(d => d.BoardNum.Equals(boardNum));
                    ViewBag.commentList = commentList;
                } catch {
                    return(RedirectToAction("Error", "Home"));
                }

                return(View(board));
            }
        }